• Home
  • Data Definition Language(DDL)

    In DDL we will know more about tables, which is the object of a database that is responsible for storing the data. Other than this we will also get to know about establishing relationship between tables and also how to alter and drop tables.

    SQL TABLE

    It is an object where we can store data. The data inside a table is arranged in a row and column format. Thus the components of a table are- records(rows), fields(columns) and data(values in each cell-row and column intersection). Each field should have a name or heading. Each row of information is called as record.

    student

    Regd.no Name Address Gender

    R103

    R105

    R107

    Sushree Panigrahi

    Sushrita Naik

    Jayadev Sahoo

    Bhubaneswar

    New Delhi

    USA

    Female

    Female

    male


    In the above table we can see that data is arranged in row and column format. The first row contains the field names(Regd.no,name,address,gender). The second row onwards are the records. R103,sushree panigrahi, Bhubaneswar, Female are values.


    SQL TABLE structure:

    A table can be created at any time while we are using the database. While creating a table, the size occupied by it is defined by the amount of space that is allocated to the database. In other words the user does not have to specify the table size. A table structure helps us to know more about a specific table, like:

    • • How many fields are there.
    • • What are the fields.
    • • What is the data type of each field.
    • • What is the size of each field.
    • • What are the constraints assigned to a field.

    SQL TABLE naming rules:
    A table name

    • • Should start with a letter.
    • • Must be within 1 to 30 character along.
    • • Can contain A-Z,a-z,0-9,_,#,$.
    • • Must not be any oracle keyword.
    • • Must not be any other object name of the same user.

    It is advisable to give meaningful names for tables and other objects . in Oracle names are case insensitive. For example STUDENT is treated as the same name as student or Student.
    How to create a SQL TABLE:
    The CREATE TABLE statement helps us to create a table. To create a table a user must have the create table privilege. The syntax of create table statement is:

    Example
    CREATE TABLE table-name
    (
        Column1   datatype1(size),
        Column2   datatype2(size),
        Column n  datatypen(size)
    );
    

    SQL CREATE TABLE Example:

    Example
    CREATE TABLE employee
    (
        emp-id  varchar2(12),
        name    char(10),
        salary  number(8),
        designation char(15)
    );
    

    The above statement create an employee table having four attributes named Emp-id, Name,, Designation. If we want to confirm the creation of the table , then the describe statement can be used.
    Syntax of describe statement:
    Describe table name;
    For example, describe employee;
    After executing this statement it will display

    Name Null Type
    emp-id varchar2(12)
    name char(10)
    salary number(8)
    designation char(15)

    The employee table can be filled with data with the INSERT INTO statement.


    About the Author



    Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.

    We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc





     PreviousNext