WEEK 5 Flashcards
(7 cards)
Question: What is the CREATE TABLE command used for in SQL?
Answer: The CREATE TABLE command is used to create a table in SQL. It requires a table name, names for all columns, data type for each column, and applicable constraints.
Question: What are some data types used in SQL?
Answer: Some data types used in SQL are:
Numeric: INT, DECIMAL(L,D)
Character/String: CHAR(L), VARCHAR(L)
Date/Time
Boolean (Yes/No)
GUID
Question: What is a constraint in SQL?
Answer: In SQL, a constraint is a restriction on a column to ensure data integrity. Examples of constraints are PRIMARY KEY, UNIQUE, NOT NULL, CHECK, and FOREIGN KEY.
Question: What is the purpose of the NOT NULL constraint in SQL?
Answer: The NOT NULL constraint in SQL ensures that a column does not accept null values.
Question: What does the UNIQUE constraint do?
Answer: The UNIQUE constraint assigns a value to an attribute when a new row is added to a table.
Question: What is the purpose of the DEFAULT constraint?
Answer: The DEFAULT constraint validates data when an attribute value is entered.
Question: What is the purpose of the CHECK constraint?
Answer: The CHECK constraint validates data when an attribute value is entered.