Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
5 views8 pages

DAY 3 SQL Server Lab1 - p3

The document outlines SQL Server commands categorized into Data Definition Language (DDL), Data Manipulation Language (DML), and Data Control Language (DCL). It provides syntax and examples for creating and altering databases and tables, as well as managing data through insertion, deletion, and updates. Additionally, it covers access control with DCL statements like Grant and Revoke.

Uploaded by

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

DAY 3 SQL Server Lab1 - p3

The document outlines SQL Server commands categorized into Data Definition Language (DDL), Data Manipulation Language (DML), and Data Control Language (DCL). It provides syntax and examples for creating and altering databases and tables, as well as managing data through insertion, deletion, and updates. Additionally, it covers access control with DCL statements like Grant and Revoke.

Uploaded by

marwa.mah1956
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 8

SQL SEVER

• Data Definition Language (DDL) : are used to define the


database structure or schema.
– Create – Drop
– Alter – Truncate

• Data Manipulation Language (DML) : are used for managing


data within schema objects.
– Insert – Delete
– Update – SELECT
• Data Control Language (DCL) statements : Used to create
roles, permissions, and referential integrity as well it is used
to control access to database by securing it.
– Grant
– Revoke
– Commit
– Rollback
DDL STATEMENTS
Create - Database

• To create a Database
– Syntax : CREATE DATABASE dbname;
– Example : CREATE DATABASE my_db;

• To Use a database
– Syntax : Use dbname;
– Example : Use my_db;
Creating a table
• Syntax • Example
CREATE
TABLE table_name CREATE TABLE Persons
( (
column_name1 PersonID int
data_type(size), identity(1,1),
column_name2 FirstName varchar(255),
data_type(size), Address varchar(255),
column_name3 City varchar(255),
data_type(size), Primary key(PersonalID)
PRIMARY );
KEY(column_name1));
DDL - Altering a table
• ALTER TABLE Persons ADD email VARCHAR(60);
• ALTER TABLE Persons DROP COLUMN city;
• ALTER TABLE Persons CHANGE FirstName FullName
VARCHAR(20);

DDL - Deleting a Table


• DROP TABLE table_name ;
DML - Examples

You might also like