0% found this document useful (0 votes)
38 views2 pages

DDL DML

Uploaded by

Prince Siva
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
38 views2 pages

DDL DML

Uploaded by

Prince Siva
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 2
yf How to drop a database ? ‘Syntax: DROP DATABASE DATABASE_NAME EXAMPLE: DROP DATABASE SIRI How to rename a database ? ‘Syntax: ALTER DATABASE DATABASE_NAME MODIFY NAME = NEW_DATABASE_NAME EXAMPLE: ALTER DATABASE SIRI MODIFY NAME = SIVAJI How to CONNECT to database ? Syntax: USE DATABASE_NAME EXAMPLE: USE SIVAJI ‘TYPES OF MS SQL SERVER COMMANDS TCL pau DOL DML DcL Create Insert Grant f- Commit Select hid Update Revoke Rollback Alter Delete Save point |— Truncate DDL Commands: > DDL(Data Definition Language) used to change the structure of the table like creating the table, altering the table, deleting the table. > DDL commands are auto committed. That means it permenantly saves all the changes in the database. 1. CREATE This command is used to create new database or table, SYNTAX ; CREATE TABLE TABLENAME (COLUMN1 Datatype, Column? Datatype, ‘COLUMN Datatype) EXAMPLE : CREATE TABLE SIRI (ID INT, NAME VARCHAR(100), AGE TINYINT) 2. ALTER This command is used to add , modify and delete columns of an existing table. SYNTAX: ALTER TABLE TABLE NAME ADD COLUMN NAME datatype EXAMPLE : ALTER TABLE SIRI ADD GENDER CHAR(1) 3. DROP This command is used to drop an existing table in a database. Also it deletes both the structure and records stored in table. SYNTAX : DROP TABLE TABLE NAME EXAMPLE : DROP TABLE EMPLOYEE_DETAILS. 4, TRUNCATE This commandis used to remove all rows ( complete data) from table . It is similar to DELETE statement with no WHERE clause. SYNTAX: TRUNCATE TABLE TABLE NAME EXAMPLE : TRUNCATE TABLE STUDENT_DETAILS, DML COMMANDS: 1. INSERT Insert statement is a SQL QUREY it is used to insert a single a or multiple records in a table. SYNTAX: INSERT INTO TABLE NAME VALUES ( VALUE 1, VLUE 2, VALUE 3) EXAMPLE: INSERT INTO STUDENTS (ROLL_NO, NAME, AGE, CITY) VALUES ( 18,’ SIVA’, 23, TIRUPATI") 2. UPDATE ‘The update statement is used to modify the existing records in a table. SYNTAX: UPDATE TABLE NAME SET COLUMN 1 = VALUE 1, COLUMN 2= VALUE 2 WHERE CONDTION EXAMPLE: UPDATE CUSTOMERS SET CONTACT NAME-’KEERTHAN’, CITY ="CHITTOOR’ WHERE CUSTOMERID=12 3,DELETE The delete statement is used to delete existing records in a table. SYNTAX: DELETE FROM TABLE NAME WHERE CONDITION EXAMPLE: DELETE FROM CUSTOMERS WHERE ID = 14

You might also like