Data Definition Language (DDL) Commands - To study the various DDL commands and implement them on the database - Computer Programming

Latest

C C++ Java Python Perl Programs Examples with Output -useful for Schools & College Students

Wednesday, October 27, 2010

Data Definition Language (DDL) Commands - To study the various DDL commands and implement them on the database

COMMANDS

SQL> create table stud (sname varchar2(30), sid varchar2(10), sage number(2), sarea varchar2(20));

Table created.

SQL> desc stud;
 Name                                                  Null?    Type
 ----------------------------------------------------- -------- --------------------------------
 SNAME                                                          VARCHAR2(30)
 SID                                                                 VARCHAR2(10)
 SAGE                                                             NUMBER(2)
 SAREA                                                          VARCHAR2(20)

SQL>alter table stud modify ( sage number(10));

Table altered.


SQL> alter table stud add ( sdept varchar2(20));

Table altered.

SQL> desc stud;
 Name                                                  Null?    Type
 ----------------------------------------------------- -------- --------------------------------
 SNAME                                                          VARCHAR2(30)
 SID                                                                 VARCHAR2(10)
 SAGE                                                             NUMBER(10)
 SAREA                                                          VARCHAR2(20)
 SDEPT                                                           VARCHAR2(20)

SQL> alter table stud drop (sdept varchar2(20));

Table altered.

SQL> desc studs;
 Name                                                  Null?    Type
 ----------------------------------------------------- -------- ------------------------------------
 SNAME                                                          VARCHAR2(30)
 SID                                                                 VARCHAR2(10)
 SAGE                                                             NUMBER(10)
 SAREA                                                          VARCHAR2(20)

SQL> truncate table studs;
Table truncated.

SQL> desc studs;
 Name                                                  Null?    Type
 ----------------------------------------------------- -------- ------------------------------------
 SNAME                                                          VARCHAR2(30)
 SID                                                                 VARCHAR2(10)
 SAGE                                                             NUMBER(10)
 SAREA                                                          VARCHAR2(20)
 SDEPT                                                           VARCHAR2(20)

SQL> drop table studs;
Table dropped.

No comments:

Post a Comment