FlashKeepers

SQL · SQL · College and University

SQL Data Types and Constraints

Common column data types and table constraints including check, unique, and foreign key, each explained with a short example.

About this set

36 basic cards for SQL SQL. It opens with "What is the CHAR data type used for?" and "What is the VARCHAR data type used for?". More College and University decks are listed below.

36 cards · basic cards · AI-written, checked twice. Edit anything.

Study this set free Look inside first Get FlashKeepers for iPhone

Opens in your browser, no account. Get the iPhone and iPad app · Android app

What is the CHAR data type used for?
Show answerFixed-length string storage. Always allocates the specified number of bytes regardless of actual string length.
What is the VARCHAR data type used for?
Show answerVariable-length string storage. Only allocates space for the actual string content, up to a maximum length.
When should you use CHAR instead of VARCHAR?
Show answerWhen you have fixed-length values, like postal codes (5 digits), state abbreviations (2 letters), or gender codes.
What is the INT data type used for?
Show answerStoring whole numbers. Typically ranges from about -2 billion to +2 billion.
What is the BIGINT data type used for?
Show answerStoring very large whole numbers, ranging from about -9 quintillion to +9 quintillion.
What is the SMALLINT data type used for?
Show answerStoring smaller whole numbers, ranging from about -32,000 to +32,000. Uses less storage than INT.
What is the DECIMAL data type used for?
Show answerStoring exact decimal numbers. Defined with precision (total digits) and scale (digits after decimal point), like DECIMAL(10,2).
What is the FLOAT data type used for?
Show answerStoring approximate decimal numbers using floating-point representation. Takes less storage than DECIMAL but may lose precision.
When should you use DECIMAL instead of FLOAT?
Show answerFor financial calculations and any scenario where exact precision is critical. DECIMAL stores values exactly, FLOAT is approximate.
What is the DATE data type used for?
Show answerStoring dates without time information. Format is typically YYYY-MM-DD.
What is the TIME data type used for?
Show answerStoring time without date information. Format is typically HH:MM:SS.
What is the DATETIME data type used for?
Show answerStoring both date and time together. Format is typically YYYY-MM-DD HH:MM:SS.
What is the BOOLEAN data type used for?
Show answerStoring true or false values. Some databases represent this as 1 for true and 0 for false.
What is the TEXT data type used for?
Show answerStoring large amounts of text data. More flexible than VARCHAR and suitable for long documents or descriptions.
What is the BLOB data type used for?
Show answerStoring binary large objects like images, audio, or video files as raw binary data.

21 more cards in the app

Study this set free