Uploaded by Y Madhu

DDL Commands (1)

advertisement
DDL Commands
1) CREATE – is used to create the database or its objects (like table, index, function,
views, store procedure and triggers).
Syntax: - Create table Tablename(column1,Column2,……)
EX:- CREATE
TABLE EMP
(EMPNO NUMERIC(4) NOT NULL,
ENAME VARCHAR(10),
JOB VARCHAR(9),
MGR NUMERIC(4),
HIREDATE DATETIME,
SAL NUMERIC(7, 2),
COMM NUMERIC(7, 2),
DEPTNO NUMERIC(2))
2) DROP – is used to delete objects from the database.
Syntax: - Drop Table Tablename
EX:- DROP
TABLE EMP
3) ALTER-is used to alter the structure of the database.
Syntax:- ALTER TABLE table_name
ADD column_name datatype;
EX:- Alter
table EMP ADD DEPTNO NUMERIC(2)
4) TRUNCATE–is used to remove all records from a table, including all spaces allocated
for the records are removed.
SX:- TRUNCATE TABLE EMP;
5) COMMENT –is used to add comments to the data dictionary.
EX:- --- for commenting one line
For Commenting multiple lines
*/ ------- */
Techieshome software solutions
techieshomeinfo@gmail.com
+91-9705341216
6) RENAME –is used to rename an object existing in the database.
Syntax: - EXEC sp_rename 'Tablename.Columnname', 'Newcolumnname';
Ex:- EXEC sp_rename 'EMP.EMPNO', 'EMPNUMBER';
Techieshome software solutions
techieshomeinfo@gmail.com
+91-9705341216
Download