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

Play all 52 questions free

Sample questions

  1. Which SQL statement is used to modify existing records in a table?

    1. ALTER TABLE
    2. MODIFY RECORD
    3. UPDATE
    4. 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.

  2. What is the purpose of a `CONSTRAINT` in SQL DDL?

    1. To define the order of rows in a table
    2. To enforce rules on the data in a table
    3. To create indexes for faster querying
    4. 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.

  3. What does the `NOT NULL` constraint enforce in SQL?

    1. That a column must contain a unique value
    2. That a column cannot have a NULL value
    3. That a column must contain a value from a predefined list
    4. 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.

  4. Which DDL statement is used to create a new user-defined function (UDF)?

    1. CREATE PROCEDURE
    2. CREATE UDF
    3. CREATE FUNCTION
    4. 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.

  5. Which SQL data type is best suited for storing boolean values (TRUE/FALSE)?

    1. INT
    2. VARCHAR
    3. BOOLEAN
    4. 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.

Take the full quiz

More quizzes

Browse all SQL quizzes