Prashant Sharma
Roll no. 17
Class. FY BBA(CA)
SQL
Structured Query Language(sql) is a programming language for storing and processing information in a relational database. SQL lets you access and manipulate databases. SQL became a standard of the American National Standards Institute (ANSI) in
1986, and of the International Organization for Standardization (ISO) in 1987. SQL was one of the first commercial languages to use Edgar F. Codd’s relational model. The model was described in his influential 1970 paper, "A Relational Model of Data for
Large Shared Data Banks".[8] Despite not entirely adhering to the relational model as described by Codd, SQL became the most widely used database language.[
SQL
Structured Query Language(sql) is a programming language for storing and processing information in a relational database. SQL lets
you access and manipulate databases. SQL became a standard of the American National Standards Institute (ANSI) in 1986, and of the
International Organization for Standardization (ISO) in 1987. SQL was one of the first commercial languages to use Edgar F.
Codd’s relational model. The model was described in his influential 1970 paper, "A Relational Model of Data for Large Shared Data
Banks".[8] Despite not entirely adhering to the relational model as described by Codd, SQL became the most widely used database
language.[
INTRODUCTION 01
DDL 02
Question & examples 03
Conclusion 04
02
• Data types
1. Char data type can be used to denote a fixed-length
string.
Example: Name char(10);
DDL
02
• Data types
1. Char data type can be used to denote a fixed-length
string.
Example: Name char(10);
A B H A Y
Name
DDL
02
• Data types
1. Char data type can be used to denote a fixed-length
string.
Example: Name char(10);
A B H A Y 1 2 3 4 5
Name
DDL
Rest 5
02
DDL
• Data types
2. Varchar/Varchar2 data type stands for varying length
character.
Example: Name char(10);
02
DDL
• Data types
3. Number data type represents a decimal number.
Example:
Roll_no number (3);
• Here 3 is representing the number of digits present.
02
DDL
Data types description
4. Int or Integer
Used for columns which will
store integer value.
5. Date Fixed-length date and time data
6. LONG
Variable-length character data
(upto 2 GB)
02
DDL
1. Create table command
 This command defines each column of table uniquely.
 Each column has minimum 3 attributes - name , data type and size.
 Syntax:
Create table <table_name> (<column name1> <data_type> (<size>),
<column_name2> <data_type> (<size>)….);
02
DDL
2. Drop table command
 Drop table statement is used to remove /delete the table entirely.
 Syntax:
Drop table <table_name>;
02
DDL
 Alter table command is used to modify the definition(structure) of
a table by modyfying the definition of its column.
 The alter table command can be used to perform the following
functions.
1) Add, drop & modify table columns
2) Add and drop constraints
§ Syntax to add a column:
Alter table <table_name> add <column_name> <datatype>;
§ Syntax to drop a column
Alter table <table_name> drop <column_name>;
3.Alter table command
02
DDL
§ Syntax to add a column:
Alter table <table_name> add <column_name> <datatype>;
§ Syntax to drop a column
Alter table <table_name> drop <column_name>;
§ Syntax to modify a column:
Alter table <table_name> modify (<column_name>
<datatype> (size);
§ Syntax to add a constraints:
Alter table <table_name> add CONSTRAINT <constraint_name>;
3.Alter table command
02
DDL
§ Syntax to modify a column:
Alter table <table_name> modify (<column_name>
<datatype> (size);
§ Syntax to add a constraints:
Alter table <table_name> add CONSTRAINT <constraint_name>;
 Syntax to delete Constraints.
Alter table <table_name> drop CONSTRAINT <constraint_name>;
3.Alter table command
Question & Examples 03
•Eg.
ALTER TABLE employee ADD (experience number(2));
•Syntax to drop a column
ALTER TABLE table_name DROP column_name;
•Eg.
ALTER TABLE employee DROP experience;
•Syntax to modify a column
ALTER TABLE table_name MODIFY (column_name datatype (size));
•Eg. ALTER TABLE employee MODIFY (salary number(15,2));
Question & Examples 03
•Syntax to add constraints:
ALTER TABLE table_name ADD CONSTRAINT constraint name ;
•Eg. 1. ALTER TABLE Persons
ADD PRIMARY KEY (ID);
2. ALTER TABLE Persons
ADD CONSTRAINT PK_Person PRIMARY KEY (ID,
LastName);
3. ALTER TABLE Orders
ADD FOREIGN KEY (ID) REFERENCES Persons(ID);
4. ALTER TABLE Persons
ADD CONSTRAINT CHK_PersonAge CHECK (Age>=18 AND City=‘Pune');
Question & Examples 03
•Syntax to delete constraints:
ALTER TABLE table_name DROP CONSTRAINT constraint name ;
•Eg.
1.ALTER TABLE Persons
DROP CONSTRAINT PK_Person;
2.ALTER TABLE Orders
DROP CONSTRAINT FK_PersonOrder;
3.ALTER TABLE Persons
DROP CONSTRAINT CHK_PersonAge;
Conclusion 04
The breadth and scope of the SQL commands provide the capability
to create and manipulate a wide variety of database objects using the
various CREATE, ALTER, and DROP commands. Those database objects
then can be loaded with data using commands such as INSERT. The
data can be manipulated using a wide variety of commands, such
as SELECT, DELETE, and TRUNCATE, as well as the cursor commands,
DECLARE, OPEN, FETCH, and CLOSE. Transactions to manipulate the
data are controlled through the SET command, plus
the COMMIT and ROLLBACK commands. And finally, other commands
covered in this chapter include those that control a user’s access to
database resources through commands such as GRANT and REVOKE.
Bibliography
• Database Management system -Nirali Prakashan publisher
• Database management System -V. K. Jain
• Wikipedia
• Notes
• Google
Thank You
Structured Query Language(sql) is a programming language for storing and processing information in a relational database. SQL lets you access and manipulate databases. SQL became a standard of the American National Standards Institute (ANSI) in
1986, and of the International Organization for Standardization (ISO) in 1987. SQL was one of the first commercial languages to use Edgar F. Codd’s relational model. The model was described in his influential 1970 paper, "A Relational Model of Data for
Large Shared Data Banks".[8] Despite not entirely adhering to the relational model as described by Codd, SQL became the most widely used database language.[

SQL ppt.pptx

  • 1.
    Prashant Sharma Roll no.17 Class. FY BBA(CA)
  • 2.
    SQL Structured Query Language(sql)is a programming language for storing and processing information in a relational database. SQL lets you access and manipulate databases. SQL became a standard of the American National Standards Institute (ANSI) in 1986, and of the International Organization for Standardization (ISO) in 1987. SQL was one of the first commercial languages to use Edgar F. Codd’s relational model. The model was described in his influential 1970 paper, "A Relational Model of Data for Large Shared Data Banks".[8] Despite not entirely adhering to the relational model as described by Codd, SQL became the most widely used database language.[
  • 3.
    SQL Structured Query Language(sql)is a programming language for storing and processing information in a relational database. SQL lets you access and manipulate databases. SQL became a standard of the American National Standards Institute (ANSI) in 1986, and of the International Organization for Standardization (ISO) in 1987. SQL was one of the first commercial languages to use Edgar F. Codd’s relational model. The model was described in his influential 1970 paper, "A Relational Model of Data for Large Shared Data Banks".[8] Despite not entirely adhering to the relational model as described by Codd, SQL became the most widely used database language.[ INTRODUCTION 01 DDL 02 Question & examples 03 Conclusion 04
  • 4.
    02 • Data types 1.Char data type can be used to denote a fixed-length string. Example: Name char(10); DDL
  • 5.
    02 • Data types 1.Char data type can be used to denote a fixed-length string. Example: Name char(10); A B H A Y Name DDL
  • 6.
    02 • Data types 1.Char data type can be used to denote a fixed-length string. Example: Name char(10); A B H A Y 1 2 3 4 5 Name DDL Rest 5
  • 7.
    02 DDL • Data types 2.Varchar/Varchar2 data type stands for varying length character. Example: Name char(10);
  • 8.
    02 DDL • Data types 3.Number data type represents a decimal number. Example: Roll_no number (3); • Here 3 is representing the number of digits present.
  • 9.
    02 DDL Data types description 4.Int or Integer Used for columns which will store integer value. 5. Date Fixed-length date and time data 6. LONG Variable-length character data (upto 2 GB)
  • 10.
    02 DDL 1. Create tablecommand  This command defines each column of table uniquely.  Each column has minimum 3 attributes - name , data type and size.  Syntax: Create table <table_name> (<column name1> <data_type> (<size>), <column_name2> <data_type> (<size>)….);
  • 11.
    02 DDL 2. Drop tablecommand  Drop table statement is used to remove /delete the table entirely.  Syntax: Drop table <table_name>;
  • 12.
    02 DDL  Alter tablecommand is used to modify the definition(structure) of a table by modyfying the definition of its column.  The alter table command can be used to perform the following functions. 1) Add, drop & modify table columns 2) Add and drop constraints § Syntax to add a column: Alter table <table_name> add <column_name> <datatype>; § Syntax to drop a column Alter table <table_name> drop <column_name>; 3.Alter table command
  • 13.
    02 DDL § Syntax toadd a column: Alter table <table_name> add <column_name> <datatype>; § Syntax to drop a column Alter table <table_name> drop <column_name>; § Syntax to modify a column: Alter table <table_name> modify (<column_name> <datatype> (size); § Syntax to add a constraints: Alter table <table_name> add CONSTRAINT <constraint_name>; 3.Alter table command
  • 14.
    02 DDL § Syntax tomodify a column: Alter table <table_name> modify (<column_name> <datatype> (size); § Syntax to add a constraints: Alter table <table_name> add CONSTRAINT <constraint_name>;  Syntax to delete Constraints. Alter table <table_name> drop CONSTRAINT <constraint_name>; 3.Alter table command
  • 15.
    Question & Examples03 •Eg. ALTER TABLE employee ADD (experience number(2)); •Syntax to drop a column ALTER TABLE table_name DROP column_name; •Eg. ALTER TABLE employee DROP experience; •Syntax to modify a column ALTER TABLE table_name MODIFY (column_name datatype (size)); •Eg. ALTER TABLE employee MODIFY (salary number(15,2));
  • 16.
    Question & Examples03 •Syntax to add constraints: ALTER TABLE table_name ADD CONSTRAINT constraint name ; •Eg. 1. ALTER TABLE Persons ADD PRIMARY KEY (ID); 2. ALTER TABLE Persons ADD CONSTRAINT PK_Person PRIMARY KEY (ID, LastName); 3. ALTER TABLE Orders ADD FOREIGN KEY (ID) REFERENCES Persons(ID); 4. ALTER TABLE Persons ADD CONSTRAINT CHK_PersonAge CHECK (Age>=18 AND City=‘Pune');
  • 17.
    Question & Examples03 •Syntax to delete constraints: ALTER TABLE table_name DROP CONSTRAINT constraint name ; •Eg. 1.ALTER TABLE Persons DROP CONSTRAINT PK_Person; 2.ALTER TABLE Orders DROP CONSTRAINT FK_PersonOrder; 3.ALTER TABLE Persons DROP CONSTRAINT CHK_PersonAge;
  • 18.
    Conclusion 04 The breadthand scope of the SQL commands provide the capability to create and manipulate a wide variety of database objects using the various CREATE, ALTER, and DROP commands. Those database objects then can be loaded with data using commands such as INSERT. The data can be manipulated using a wide variety of commands, such as SELECT, DELETE, and TRUNCATE, as well as the cursor commands, DECLARE, OPEN, FETCH, and CLOSE. Transactions to manipulate the data are controlled through the SET command, plus the COMMIT and ROLLBACK commands. And finally, other commands covered in this chapter include those that control a user’s access to database resources through commands such as GRANT and REVOKE.
  • 19.
    Bibliography • Database Managementsystem -Nirali Prakashan publisher • Database management System -V. K. Jain • Wikipedia • Notes • Google
  • 20.
    Thank You Structured QueryLanguage(sql) is a programming language for storing and processing information in a relational database. SQL lets you access and manipulate databases. SQL became a standard of the American National Standards Institute (ANSI) in 1986, and of the International Organization for Standardization (ISO) in 1987. SQL was one of the first commercial languages to use Edgar F. Codd’s relational model. The model was described in his influential 1970 paper, "A Relational Model of Data for Large Shared Data Banks".[8] Despite not entirely adhering to the relational model as described by Codd, SQL became the most widely used database language.[