Any2Quiz
Quizzes / Computer Science / Languages / SQL

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, free

Sample questions

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

Take the full quiz

More questions in this quiz

Answers and explanations are in the full quiz.

  1. Which of the following is NOT a valid DDL statement in SQL?
  2. What is the primary purpose of a `CREATE TABLE` statement in SQL?
  3. Which SQL keyword is used to remove a table from the database?
  4. What does the `ALTER TABLE` statement allow you to do?
  5. 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?
  6. Which DDL command is used to create an index on one or more columns of a table to speed up data retrieval?
  7. What is the difference between `DROP TABLE` and `TRUNCATE TABLE`?
  8. Which of the following is a valid data type for storing a date in SQL?
  9. When adding a `FOREIGN KEY` constraint, what must the referenced column in the other table have?
  10. Which SQL statement is used to add a new column to an existing table?
  11. What does `VARCHAR(n)` typically represent in SQL data types?
  12. Which statement is used to create a database view?
  13. Which of the following is a DDL statement used to modify the structure of a table by renaming it?
  14. When defining a `CHECK` constraint, what is its purpose?
  15. What is the SQL keyword used to create a new database?
  16. Which DDL statement allows you to define the structure for a new schema within a database?
  17. What is the purpose of a `UNIQUE` constraint in SQL?
  18. Which of the following SQL data types is most suitable for storing a large text document?
  19. Which SQL statement is used to create a new user account in a database system?
  20. What is the effect of executing `ALTER TABLE Customers DROP COLUMN Email;`?
  21. Which DDL command is used to create a stored procedure?
  22. What is the data type `DECIMAL(p, s)` used for in SQL?
  23. When using `ALTER TABLE` to add a constraint, what is the typical syntax for adding a `FOREIGN KEY`?
  24. What is the primary function of a `PRIMARY KEY` constraint on a table?
  25. Which SQL DDL statement is used to create a database trigger?
  26. What is the main difference between `CREATE TABLE` and `CREATE VIEW`?
  27. Consider `ALTER TABLE Products ADD CONSTRAINT PK_ProductID PRIMARY KEY (ProductID);`. What does this statement accomplish?
  28. What is the purpose of a `DEFAULT` constraint in SQL?
  29. What is the SQL data type `FLOAT` typically used for?
  30. Which of the following SQL statements modifies the data type of an existing column?
  31. What is the purpose of the `CASCADE` option when defining a `FOREIGN KEY` constraint with `ON DELETE` or `ON UPDATE`?
  32. Which SQL DDL command is used to create a schema that groups related database objects?
  33. What does `IDENTITY` or `AUTO_INCREMENT` typically signify when used with a column definition in SQL?
  34. Which SQL statement is used to remove a database from the system?
  35. What is the purpose of the `REPLACE` keyword in some SQL `CREATE` statements (e.g., `CREATE OR REPLACE VIEW`)?
  36. Which SQL statement can be used to add a `CHECK` constraint to an existing column?
  37. What is the primary purpose of the `FOREIGN KEY` constraint?
  38. What does the `ON DELETE SET NULL` clause do when defining a `FOREIGN KEY` constraint?
  39. Which DDL statement is used to create a unique index on a table?
  40. What is the purpose of a `TRUNCATE TABLE` statement?
  41. Which SQL statement is used to create a new database user with specific privileges?
  42. What is the function of the `REFERENCES` clause when defining a `FOREIGN KEY` constraint?
  43. Which of the following is a DDL statement for defining a new table with specific columns and data types?
  44. What is the purpose of the `ON DELETE RESTRICT` or `ON DELETE NO ACTION` clause for a `FOREIGN KEY` constraint?
  45. When altering a table, what does `ALTER TABLE ... ALTER COLUMN column_name SET NOT NULL;` achieve?
  46. Which DDL statement is used to create a new database role?
  47. What is the purpose of the `COMMENT ON` statement in SQL?

More quizzes

Browse all SQL quizzes

More to play

Daily ChallengeA new quiz every day. Keep your streak.HangmanGuess the word, letter by letter.Story QuestLearn through short interactive stories.All quizzesCBSE, ICSE, competitive exams and more.