DDL Quiz - Languages SQL
Free practice quiz: DDL (Languages SQL). 52 multiple-choice questions with answers and explanations. Play online, no sign-up needed.
Play all 52 questions freeSample questions
Which SQL statement is used to modify existing records in a table?
- ALTER TABLE
- MODIFY RECORD
- UPDATE
- CHANGE RECORD
Show answer
Answer: C. UPDATE
The UPDATE statement is used to modify existing records in a table. ALTER TABLE is used to modify the table structure. MODIFY RECORD and CHANGE RECORD are not standard SQL commands for this purpose.
What is the purpose of a `CONSTRAINT` in SQL DDL?
- To define the order of rows in a table
- To enforce rules on the data in a table
- To create indexes for faster querying
- To define relationships between tables
Show answer
Answer: B. To enforce rules on the data in a table
Constraints are DDL elements used to enforce data integrity and business rules. Examples include `PRIMARY KEY`, `UNIQUE`, `FOREIGN KEY`, `NOT NULL`, and `CHECK` constraints.
What does the `NOT NULL` constraint enforce in SQL?
- That a column must contain a unique value
- That a column cannot have a NULL value
- That a column must contain a value from a predefined list
- That a column cannot be modified
Show answer
Answer: B. That a column cannot have a NULL value
The `NOT NULL` constraint ensures that a column cannot contain `NULL` values. Every row must have a value in such a column.
Which DDL statement is used to create a new user-defined function (UDF)?
- CREATE PROCEDURE
- CREATE UDF
- CREATE FUNCTION
- CREATE ROUTINE
Show answer
Answer: C. CREATE FUNCTION
`CREATE FUNCTION` is the DDL statement used to define and create user-defined functions, which are stored procedures that return a single value.
Which SQL data type is best suited for storing boolean values (TRUE/FALSE)?
- INT
- VARCHAR
- BOOLEAN
- DECIMAL
Show answer
Answer: C. BOOLEAN
The `BOOLEAN` data type is specifically designed to store logical values, typically represented as TRUE or FALSE. Some SQL dialects might use `BIT` or other representations.