DATABASE & SQL/PLSQL

adplus-dvertising
DDL (Data Definition Language)
Previous Home Next

Data Definition Language (DDL) statements are used to define the database structure or schema. DDL statements are used to build and modify the structure of your tables and other objects in the database. When you execute a DDL statement, it takes effect immediately.

  1. CREATE: To create objects in the database
  2. CREATE TABLE < table_name> ( <attribute_name 1> <data_type 1>,
    <attribute_name n> <data_type n>);
    
  3. ALTER: Alters the structure of the database
  4. ALTER TABLE <table_name>ADD CONSTRAINT <constraint_name>
    PRIMARY KEY (<attribute_list>);
    

    The foreign key constraint is a bit more complicated, since we have to specify both the Foreign Key attributes in this (child) table, and the Primary Key attributes that they link to in the parent table.

    ALTER TABLE <table_name>ADD CONSTRAINT <constraint_name>
    FOREIGN KEY (<attribute_list>)REFERENCES <parent_table_name> 
    (<attribute_list>);
    
  5. DROP: Delete objects from the database
  6. DROP TABLE <table_name>ALTER TABLE <table_name>
    DROP CONSTRAINT <constraint name>;
    
  7. TRUNCATE: Remove all records from a table, including all spaces allocated for the records are removed
  8. COMMENT: Comments added to the data dictionary.
  9. RENAME: Rename an object of the Database.
Previous Home Next