DATA DICTIONARY LANGUAGE (DDL) ( CREATE, ALTER, DROP, TRUNCATE, RENAME)
Creating a table
create table Employee (empno number(2),ename varchar2(30), sal number(10,2) ) ;-------------------------------------- create acreate table student (rollno number(4),sname varchar2(20),DOB date, Branch varchar2(20));
Altering a table by using Add, Modify, Drop, Rename
alter table student add address varchar(100) ;alter table stdeunt add (address1 varchar(100), fname varchar2(30)) ;alter table student modify (address varchar2(50), address1 varchar2(50)) ;
- Dropping a column in student table alter table student drop column address1 ;
- To drop multiple columns at a time is: Alter table student drop (FNAME, branch) ;
- To renaming a column Alter table emp rename column ename to empname ;
- To seeting the Unused columns SAL in EMP table Alter table emp set UNUSED COLUMN Sal;
- Dropping the unused columnfrom the EMPtableAlter table emp DROP UNUSED COLUMNS;
Dropping a table
Drop table tablename ;
DROP table tname ;Drop table emp1 ;
Truncating a Table truncate table dept;
Renaming a table Rename oldtablename to newtabalename; Rename emp to emp1 ;
No comments:
Post a Comment