Data Definition Language(DDL) Commands in RDBMS


DDL QUERIES:


             1.CREATE COMMAND:
                    Syntax:
                                 Create table tablename (column element fieldname column description);
                    It is used to create a new table.

            2.ALTER COMMAND:
                  Syntax:
                                Alter table tablename add on modify(column name datatypes size);
                 It is used for adding the values and also for modifying the table.


           3.SELECT COMMAND:
                 Syntax:
                               Select * from tablename;
                It is used for displaying the contents of the table
.
           4.TRUNCATE COMMAND:
                 Syntax:
                               Truncate table tablename;
                The contents of the table are deleted(truncate).

            5.DROP COMMAND:
                   Syntax:
                               Drop table tablename;
                    The whole table ifself is delected.


OUTPUT:

SQL> create table robo(name varchar(10),brand number(5));
Table created.
SQL> desc robo
 Name                            Null?    Type
 ------------------------------- -------- ----
 NAME                                     VARCHAR2(10)
 BRAND                                    NUMBER(5)

SQL> insert into robo values('&name','&brand');
Enter value for name: priya
Enter value for brand: 100
old   1: insert into robo values('&name','&brand')
new   1: insert into robo values('priya','100')
1 row created.

SQL> insert into robo values('&name','&brand');
Enter value for name: riya
Enter value for brand: 1001
old   1: insert into robo values('&name','&brand')
new   1: insert into robo values('riya','1001')

1 row created.

SQL> insert into robo values('&name','&brand');
Enter value for name: supriya
Enter value for brand: 10011
old   1: insert into robo values('&name','&brand')
new   1: insert into robo values('supriya','10011')
1 row created.

SQL> select * from robo;
NAME           BRAND
---------- ---------
priya            100
riya            1001
supriya        10011

SQL> alter table robo add(price number(5));
Table altered.

SQL> desc robo
 Name                            Null?    Type
 ------------------------------- -------- ----
 NAME                                     VARCHAR2(10)
 BRAND                                    NUMBER(5)
 PRICE                                    NUMBER(5)

SQL> alter table robo modify(price number(5));
Table altered.

SQL> desc robo

 Name                            Null?    Type
 ------------------------------- -------- ----
 NAME                                     VARCHAR2(10)
 BRAND                                    NUMBER(5)
 PRICE                                    NUMBER(5)
SQL> truncate table robo;
Table truncated.
SQL> desc robo
 Name                            Null?    Type
 ------------------------------- -------- ----
 NAME                                     VARCHAR2(10)
 BRAND                                    NUMBER(5)
 PRICE                                    NUMBER(5)
SQL> select * from robo;
no rows selected

SQL> drop table robo;
Table dropped.

0 comments:

Post a Comment