- DDL stands for Data Definition Languages .
- DDL Commands Used for create and modify the structure of the Objects ,Views, Sequences,Indexes, Schemas etc.
- Data Definition Languages is one of the Sub Language.
- the commands of the DDL Language is
- Create
- Alter
- Truncate
- Drop
- Rename(Replace)
1. Create
- It is used to create the Tables, Views, Functions, Synonyms etc.
- CREATING TABLE
CREATE TABLE MYSHOPSTAP
(
ID NUMBER PRIMARY KEY,
WORKER_NAME VARCHAR2(20),
DEPTNO NUMBER
);
Table created.
SQL> COMMIT;
Commit complete.
SELECT * FROM MYSHOPSTAP;
ID WORKER_NAME DEPTNO
---------- -------------------- ---------
1 SAKHI 100
2 KRISH 101
3 KISHORE 101
4 GOPI 102
.
2. Rename
- It is used to rename the Tables .
- It one of the DDL Command
RENAME MYSHOPSTAP TO MYSHOP;
3. Alter
- It is used to alter the existing table .
- The operations happen in Column level only.
- We can Delete the Column ,We can Rename the Column, We can Modify the Column, Enable, Disable the Columns and we can add the Column.
- The Sub Commands of Alter are 1)Add, 2) Modify, 3) Drop, 4) Rename,5) Enable, 5)Disable
- The Sub Commands are apply on Records of the Tables,Views.
ADD :
ALTER TABLE MYSHOP
ADD
(
CITY VARCHAR2(20)
);
MODIFY :
ALTER TABLE MYSHOP
ADD
(
CITY VARCHAR2(100)
);
DROP :
ALTER TABLE MYSHOP
DROP COLUMN CITY;
RENAME :
ALTER TABLE MYSHOP
RENAME COLUMN WORKER_NAME TO NAME;
4. Truncate
- It is used to Delete all the records of the the tables Permanently but structure remains same.
- It is one of the sub command of DDL Command.
- Roll Back will not generate the to get back the Data
TRUNCATE TABLE MYSHOP;
5 Drop
- It is used to Delete the Table Permanently
- it is one of the Sub Language.
DROP TABLE MYSHOP;
Top Searching Topics
Indexes in oracle with examples.
No comments:
Post a Comment