DDL Quiz - Languages SQL
Free practice quiz: DDL (Languages SQL). 52 multiple-choice questions with answers and explanations. Play online, no sign-up needed.
This Languages SQL practice quiz has 52 multiple-choice questions on DDL, and 52 of them come with an explanation. Try the 5 sample questions below (tap an option to check yourself), then play the full quiz online. No sign-up needed.
Start quiz: 52 questions, freeSample questions
Which SQL statement is used to modify existing records in a table?
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?
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?
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)?
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)?
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.
More questions in this quiz
Answers and explanations are in the full quiz.
- Which of the following is NOT a valid DDL statement in SQL?
- What is the primary purpose of a `CREATE TABLE` statement in SQL?
- Which SQL keyword is used to remove a table from the database?
- What does the `ALTER TABLE` statement allow you to do?
- Consider the following SQL statement: `CREATE TABLE Employees (EmployeeID INT PRIMARY KEY, FirstName VARCHAR(50), LastName VARCHAR(50));` What does `PRIMARY KEY` signify in this context?
- Which DDL command is used to create an index on one or more columns of a table to speed up data retrieval?
- What is the difference between `DROP TABLE` and `TRUNCATE TABLE`?
- Which of the following is a valid data type for storing a date in SQL?
- When adding a `FOREIGN KEY` constraint, what must the referenced column in the other table have?
- Which SQL statement is used to add a new column to an existing table?
- What does `VARCHAR(n)` typically represent in SQL data types?
- Which statement is used to create a database view?
- Which of the following is a DDL statement used to modify the structure of a table by renaming it?
- When defining a `CHECK` constraint, what is its purpose?
- What is the SQL keyword used to create a new database?
- Which DDL statement allows you to define the structure for a new schema within a database?
- What is the purpose of a `UNIQUE` constraint in SQL?
- Which of the following SQL data types is most suitable for storing a large text document?
- Which SQL statement is used to create a new user account in a database system?
- What is the effect of executing `ALTER TABLE Customers DROP COLUMN Email;`?
- Which DDL command is used to create a stored procedure?
- What is the data type `DECIMAL(p, s)` used for in SQL?
- When using `ALTER TABLE` to add a constraint, what is the typical syntax for adding a `FOREIGN KEY`?
- What is the primary function of a `PRIMARY KEY` constraint on a table?
- Which SQL DDL statement is used to create a database trigger?
- What is the main difference between `CREATE TABLE` and `CREATE VIEW`?
- Consider `ALTER TABLE Products ADD CONSTRAINT PK_ProductID PRIMARY KEY (ProductID);`. What does this statement accomplish?
- What is the purpose of a `DEFAULT` constraint in SQL?
- What is the SQL data type `FLOAT` typically used for?
- Which of the following SQL statements modifies the data type of an existing column?
- What is the purpose of the `CASCADE` option when defining a `FOREIGN KEY` constraint with `ON DELETE` or `ON UPDATE`?
- Which SQL DDL command is used to create a schema that groups related database objects?
- What does `IDENTITY` or `AUTO_INCREMENT` typically signify when used with a column definition in SQL?
- Which SQL statement is used to remove a database from the system?
- What is the purpose of the `REPLACE` keyword in some SQL `CREATE` statements (e.g., `CREATE OR REPLACE VIEW`)?
- Which SQL statement can be used to add a `CHECK` constraint to an existing column?
- What is the primary purpose of the `FOREIGN KEY` constraint?
- What does the `ON DELETE SET NULL` clause do when defining a `FOREIGN KEY` constraint?
- Which DDL statement is used to create a unique index on a table?
- What is the purpose of a `TRUNCATE TABLE` statement?
- Which SQL statement is used to create a new database user with specific privileges?
- What is the function of the `REFERENCES` clause when defining a `FOREIGN KEY` constraint?
- Which of the following is a DDL statement for defining a new table with specific columns and data types?
- What is the purpose of the `ON DELETE RESTRICT` or `ON DELETE NO ACTION` clause for a `FOREIGN KEY` constraint?
- When altering a table, what does `ALTER TABLE ... ALTER COLUMN column_name SET NOT NULL;` achieve?
- Which DDL statement is used to create a new database role?
- What is the purpose of the `COMMENT ON` statement in SQL?