Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Data Definition Language

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 552
    Comment on it

    These statements define the structure of the database. DDL consist of those statements that create,alter and drop database objects and statements that grant and revoke privileges and roles to user  of the database.

    Statements under this category are:

    CREATE 

    ALTER

    DROP

    GRANT

    REVOKE etc.

    Creating Database objects: Create command

    Create statement used to create database objects.

    e.g. Tables,Views, Synonyms etc.

    Syntax of the CREATE TABLE statement

    CREATE TABLE Table-name
    
    ( Column-name 1 data-type[column constraint],
    
     Column-name 2 data-type[column constraint],
    
     -              -                 -
    
     -              -                 -
    
    Column-name ndata-type[column constraint],
    
    [Table-constraints]  );
    

    Following statement creates an EMPLOYEE -DETAILS table:

    CREATE TABLE Employee-details
    
    (  Emp_No       Number(6) PRIMARY KEY
    
      Emp_Name      Char(6) NOT NULL
    
      DEPT        Char(20)
    
      SALARY       Number
    
        Constraint     DEPT_CHECK
    
     CHECK(DEPT IN ('ACCOUNT','PERSONNEL','ADMIN'))
    
    );

    Altering definition of table : Alter command

    ALTER TABLE command is used to alter the definition of a table in the database.

    Syntax of the command:

    ALTER TABLE Table_name
    
    ADD           column-name data_type           [column_constraint],
    
    [MODIFY         column-name data_type           [column_constraint]];
    
    e.g. Alter table Employee-details add age number.
    

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: