10.3.1 Data definition language (DDL)

    Cards (99)

    • What does DDL stand for in SQL?
      Data Definition Language
    • DDL in SQL is used to define and manage the structure of a database
    • Name three common DDL commands in SQL.
      CREATE, ALTER, DROP
    • The CREATE command in DDL is used to define new tables.
    • Within tables, DDL allows you to define columns and their data types
    • What are primary keys and foreign keys used for in DDL?
      Specifying relationships between tables
    • The ALTER command in DDL can be used to modify the structure of existing tables.
    • Using the ALTER command, you can add, modify, or delete columns
    • What is the purpose of the RENAME command in DDL?
      Rename tables
    • The DROP command in DDL is used to delete entire tables.
    • DDL is a subset of SQL used to define and manage the structure of a database
    • What is the purpose of the CREATE command in DDL?
      Defines new database objects
    • What is the purpose of the ALTER command in DDL?
      Modifies existing database objects
    • What is the purpose of the DROP command in DDL?
      Removes database objects
    • The TRUNCATE command in DDL empties a table while keeping its structure intact.
    • The CREATE command in DDL is used to define new database objects, primarily tables
    • What is the basic syntax for the CREATE TABLE command in DDL?
      CREATE TABLE TableName ( ColumnName1 DataType1, ColumnName2 DataType2, ... );</latex>
    • What does DDL stand for in SQL?
      Data Definition Language
    • Key DDL commands include CREATE, ALTER, DROP, and TRUNCATE
    • What is the primary function of the CREATE command in DDL?
      Defines new database objects
    • The ALTER command in DDL is used to modify existing database objects.
    • The TRUNCATE command empties a table while keeping its structure
    • Which DDL command modifies existing database objects?
      ALTER
    • What is the purpose of the DROP command in DDL?
      Removes database objects
    • The TRUNCATE command removes the table structure along with the data.
      False
    • What is the basic syntax for the CREATE TABLE command in DDL?
      CREATETABLETableName(ColumnName1DataType1,...);CREATE TABLE TableName ( ColumnName1 DataType1, ... );
    • Common data types used in SQL include INT, VARCHAR, DATE, and FLOAT
    • What type of data is stored in a column with the INT data type?
      Whole numbers
    • What is the purpose of the DATE data type in SQL?
      Stores calendar dates
    • Match the primary key feature with its description:
      Purpose ↔️ Uniquely identify each row
      Usage ↔️ Each table must have one
      Values ↔️ Must be unique and non-null
    • What is an example of a primary key constraint in SQL?
      StudentIDINTPRIMARYKEYStudentID INT PRIMARY KEY
    • A table can have multiple primary keys.
      False
    • Primary key values must be unique and non-null
    • What is an example of a foreign key constraint in SQL?
      CourseID INT FOREIGN KEY REFERENCES Courses(CourseID)</latex>
    • The DROP COLUMN command is used to delete an existing column in a table.
    • What is the syntax to add a column to an existing table using the ALTER TABLE command?
      ALTERTABLETableNameADDCOLUMNColumnNameDataType;ALTER TABLE TableName ADD COLUMN ColumnName DataType;
    • To modify the data type of a column, you use the ALTER TABLE command with the MODIFY COLUMN clause.
    • Order the actions performed on a table using the ALTER TABLE command:
      1️⃣ Add a column
      2️⃣ Modify a column
      3️⃣ Drop a column
    • What command is used to modify the structure of an existing table in SQL?
      ALTER TABLE
    • To add a column in a table, the syntax is ALTER TABLE TableName ADD COLUMN ColumnName DataType;