SlideShare a Scribd company logo
Relational database
language
Prepared By
Ms. Sheethal Aji Mani
Assistant Professor
Kristu Jayanti College
 Basic Data Types
• Number
• Char
• Varchar and Varchar2
• Date and Time
 DDL(Data Definition Language) : DDL or Data Definition Language actually consists of the SQL commands that can be used to
define the database schema. It simply deals with descriptions of the database schema and is used to create and modify the
structure of database objects in the database.
• DDL stands for Data Definition Language.
• It is a language used for defining and modifying the data and its structure.
• It is used to build and modify the structure of your tables and other objects in the database.
 SQLs data definition language (DDL) defines information about each relation in a database which is listed below in detail:
• SQLs DDL specifies the schema of each relation i.e. the logical design of each relation which states the name of that
relation, attributes it carry and also specifies the domain of those attributes.
• SQL DDL specifies the integrity constraint which makes sure that any changes made to the database don’t affect the
consistency of data.
• SQL DDL also maintains the set of indices for each relation which let you retrieve the records from the database quickly.
• SQL DDL maintains the information about the security of data in the database and it also keeps the information regarding
the authorization for each relation in the database.
• SQL DDL also describes the storage structure of each relation on the hard disk.
 Examples of DDL commands:
• CREATE – is used to create the database or its objects (like table, index,
function, views, store procedure and triggers).
• DROP – is used to delete objects from the database.
• ALTER-is used to alter the structure of the database.
• TRUNCATE–is used to remove all records from a table, including all spaces
allocated for the records are removed.
• COMMENT –is used to add comments to the data dictionary.
• RENAME –is used to rename an object existing in the database.
1. CREATE COMMAND
• CREATE command is used for creating objects in the database.
• It creates a new table.
 Syntax:
CREATE TABLE <table_name>
( column_name1 datatype,
column_name2 datatype,
.
.
.
column_name_n datatype
);
Example : CREATE command
 CREATE TABLE employee
(
empid INT,
ename CHAR,
age INT,
city CHAR(25),
phone_no VARCHAR(20)
);
2. DROP COMMAND
• DROP command allows to remove entire database objects from the database.
• It removes entire data structure from the database.
• It deletes a table, index or view.

Syntax:
DROP TABLE <table_name>;
OR
DROP DATABASE <database_name>;
Example : DROP Command
 DROP TABLE employee;
OR
DROP DATABASE employees;
•
If you want to remove individual records, then use DELETE command of the DML statement.
3. ALTER COMMAND
• An ALTER command allows to alter or modify the
structure of the database.
• It modifies an existing database object.
• Using this command, you can add additional
column, drop existing column and even change
the data type of columns.
 Syntax:
ALTER TABLE <table_name>
ADD <column_name datatype>;
OR
ALTER TABLE <table_name>
CHANGE <old_column_name>
<new_column_name>;
OR
ALTER TABLE <table_name>
DROP COLUMN <column_name>;
Example : ALTER Command
ALTER TABLE employee
ADD (address varchar2(50));
OR
ALTER TABLE employee
CHANGE (phone_no) (contact_no);
OR
ALTER TABLE employee
DROP COLUMN age;
To view the changed structure of table, use 'DESCRIBE'
command.
For example:
DESCRIBE TABLE employee;
4. RENAME COMMAND
• RENAME command is used to rename an object.
• It renames a database table.
 Syntax:
RENAME TABLE <old_name> TO <new_name>;
Example:
RENAME TABLE emp TO employee;
5. TRUNCATE COMMAND
• TRUNCATE command is used to delete all the rows from the table
permanently.
• It removes all the records from a table, including all spaces allocated for the
records.
• This command is same as DELETE command, but TRUNCATE command does
not generate any rollback data.
 Syntax:
TRUNCATE TABLE <table_name>;
Example:
TRUNCATE TABLE employee;
Queries
 The SQL SELECT statement is used to fetch the data from a database table which returns this
data in the form of a result table. These result tables are called result-sets.
 Syntax
If you want to fetch all the fields available in the field, then
you can use the following syntax.
where clause
 The SQL WHERE clause is used to specify a condition while fetching the data
from a single table or by joining with multiple tables. If the given condition is
satisfied, then only it returns a specific value from the table. You should use the
WHERE clause to filter the records and fetching only the necessary records.
 The WHERE clause is not only used in the SELECT statement, but it is also
used in the UPDATE, DELETE statement, etc., which we would examine in the
subsequent chapters.

AND operator
 The SQL AND & OR operators are used to combine multiple conditions to
narrow data in an SQL statement. These two operators are called as the
conjunctive operators.
 These operators provide a means to make multiple comparisons with different
operators in the same SQL statement.
 The AND Operator
 The AND operator allows the existence of multiple conditions in an SQL
statement's WHERE clause.
OR
Insert
Update
Delete statement
 The SQL DELETE Query is used to delete the existing records from a
table.
 You can use the WHERE clause with a DELETE query to delete the
selected rows, otherwise all the records would be deleted.
View in SQL
 view is nothing more than a SQL statement that is stored in the database with an associated name.
A view is actually a composition of a table in the form of a predefined SQL query.
 A view can contain all rows of a table or select rows from a table.
 A view can be created from one or many tables which depends on the written SQL query to create a
view.
 Views, which are a type of virtual tables allow users to do the following −
• Structure data in a way that users or classes of users find natural or intuitive.
• Restrict access to the data in such a way that a user can see and (sometimes) modify exactly what
they need and no more.
• Summarize data from various tables which can be used to generate reports.
Creating Views
General Constraints
Constraints are the rules enforced on the data columns of a table. These are used to limit the
type of data that can go into a table. This ensures the accuracy and reliability of the data in
the database.
Constraints could be either on a column level or a table level. The column level constraints
are applied only to one column, whereas the table level constraints are applied to the whole
table.
Dropping Constraints
 Any constraint that you have defined can be dropped using the ALTER TABLE
command with the DROP CONSTRAINT option.
 For example, to drop the primary key constraint in the EMPLOYEES table, you
can use the following command.
Indexes
 Indexes are special lookup tables that the database search engine can use to
speed up data retrieval.
 Simply put, an index is a pointer to data in a table.
 An index in a database is very similar to an index in the back of a book.
 For example, if you want to reference all pages in a book that discusses a
certain topic, you first refer to the index, which lists all the topics alphabetically
and are then referred to one or more specific page numbers.
 An index helps to speed up SELECT queries and WHERE clauses, but it slows
down data input, with the UPDATE and the INSERT statements.
 Indexes can be created or dropped with no effect on the data.
Additional Features
• SQL is easy to learn.
• SQL is used to access data from relational database management systems.
• SQL can execute queries against the database.
• SQL is used to describe the data.
• SQL is used to define the data in the database and manipulate it when needed.
• SQL is used to create and drop the database and table.
• SQL is used to create a view, stored procedure, function in a database.
• SQL allows users to set permissions on tables, procedures, and views.
Advantages of SQL
 There are the following advantages of SQL:
 High speed
 Using the SQL queries, the user can quickly and efficiently retrieve a large amount of records from
a database.
 No coding needed
 In the standard SQL, it is very easy to manage the database system. It doesn't require a
substantial amount of code to manage the database system.
 Well defined standards
 Long established are used by the SQL databases that are being used by ISO and ANSI.
 Portability
 SQL can be used in laptop, PCs, server and even some mobile phones.
 Interactive language
 SQL is a domain language used to communicate with the database. It is also used to receive
answers to the complex questions in seconds.
 Multiple data view
 Thankyou

More Related Content

Similar to Relational Database Language.pptx

Introduction to SQL, SQL*Plus
Introduction to SQL, SQL*PlusIntroduction to SQL, SQL*Plus
Introduction to SQL, SQL*Plus
Chhom Karath
 
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptxMy lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
EliasPetros
 
Sql basic things
Sql basic thingsSql basic things
Sql basic things
Nishil Jain
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
Rumman Ansari
 
MySQL Essential Training
MySQL Essential TrainingMySQL Essential Training
MySQL Essential Training
HudaRaghibKadhim
 
sql-commands.pdf
sql-commands.pdfsql-commands.pdf
sql-commands.pdf
Prof. Dr. K. Adisesha
 
Sql commands
Sql commandsSql commands
Sql commands
Prof. Dr. K. Adisesha
 
Sql commands
Sql commandsSql commands
Sql commands
Prof. Dr. K. Adisesha
 
SQL SERVER Training in Pune Slides
SQL SERVER Training in Pune SlidesSQL SERVER Training in Pune Slides
SQL SERVER Training in Pune Slides
enosislearningcom
 
Adbms
AdbmsAdbms
Adbms
jass12345
 
SQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdfSQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdf
DraguClaudiu
 
Lecture on DBMS & MySQL.pdf v. C. .
Lecture on DBMS & MySQL.pdf v.  C.     .Lecture on DBMS & MySQL.pdf v.  C.     .
Lecture on DBMS & MySQL.pdf v. C. .
MayankSinghRawat6
 
SQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics CoveredSQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics Covered
Danish Mehraj
 
20190326165338_ISYS6508-PPT5-W5-S6-R0.pptx
20190326165338_ISYS6508-PPT5-W5-S6-R0.pptx20190326165338_ISYS6508-PPT5-W5-S6-R0.pptx
20190326165338_ISYS6508-PPT5-W5-S6-R0.pptx
FayChan8
 
SQL
SQLSQL
Structure Query Language (SQL).pptx
Structure Query Language (SQL).pptxStructure Query Language (SQL).pptx
Structure Query Language (SQL).pptx
NalinaKumari2
 
Structure query language (sql)
Structure query language (sql)Structure query language (sql)
Structure query language (sql)
Nalina Kumari
 
Dms 22319 micro project
Dms 22319 micro projectDms 22319 micro project
Dms 22319 micro project
ARVIND SARDAR
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
paddu123
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
paddu123
 

Similar to Relational Database Language.pptx (20)

Introduction to SQL, SQL*Plus
Introduction to SQL, SQL*PlusIntroduction to SQL, SQL*Plus
Introduction to SQL, SQL*Plus
 
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptxMy lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
My lablkxjlkxjcvlxkcjvlxckjvlxck ppt.pptx
 
Sql basic things
Sql basic thingsSql basic things
Sql basic things
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
 
MySQL Essential Training
MySQL Essential TrainingMySQL Essential Training
MySQL Essential Training
 
sql-commands.pdf
sql-commands.pdfsql-commands.pdf
sql-commands.pdf
 
Sql commands
Sql commandsSql commands
Sql commands
 
Sql commands
Sql commandsSql commands
Sql commands
 
SQL SERVER Training in Pune Slides
SQL SERVER Training in Pune SlidesSQL SERVER Training in Pune Slides
SQL SERVER Training in Pune Slides
 
Adbms
AdbmsAdbms
Adbms
 
SQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdfSQL -Beginner To Intermediate Level.pdf
SQL -Beginner To Intermediate Level.pdf
 
Lecture on DBMS & MySQL.pdf v. C. .
Lecture on DBMS & MySQL.pdf v.  C.     .Lecture on DBMS & MySQL.pdf v.  C.     .
Lecture on DBMS & MySQL.pdf v. C. .
 
SQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics CoveredSQL Complete Tutorial. All Topics Covered
SQL Complete Tutorial. All Topics Covered
 
20190326165338_ISYS6508-PPT5-W5-S6-R0.pptx
20190326165338_ISYS6508-PPT5-W5-S6-R0.pptx20190326165338_ISYS6508-PPT5-W5-S6-R0.pptx
20190326165338_ISYS6508-PPT5-W5-S6-R0.pptx
 
SQL
SQLSQL
SQL
 
Structure Query Language (SQL).pptx
Structure Query Language (SQL).pptxStructure Query Language (SQL).pptx
Structure Query Language (SQL).pptx
 
Structure query language (sql)
Structure query language (sql)Structure query language (sql)
Structure query language (sql)
 
Dms 22319 micro project
Dms 22319 micro projectDms 22319 micro project
Dms 22319 micro project
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
 
Sql smart reference_by_prasad
Sql smart reference_by_prasadSql smart reference_by_prasad
Sql smart reference_by_prasad
 

Recently uploaded

Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
AzmatAli747758
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 

Recently uploaded (20)

Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 

Relational Database Language.pptx

  • 1. Relational database language Prepared By Ms. Sheethal Aji Mani Assistant Professor Kristu Jayanti College
  • 2.  Basic Data Types • Number • Char • Varchar and Varchar2 • Date and Time
  • 3.  DDL(Data Definition Language) : DDL or Data Definition Language actually consists of the SQL commands that can be used to define the database schema. It simply deals with descriptions of the database schema and is used to create and modify the structure of database objects in the database. • DDL stands for Data Definition Language. • It is a language used for defining and modifying the data and its structure. • It is used to build and modify the structure of your tables and other objects in the database.  SQLs data definition language (DDL) defines information about each relation in a database which is listed below in detail: • SQLs DDL specifies the schema of each relation i.e. the logical design of each relation which states the name of that relation, attributes it carry and also specifies the domain of those attributes. • SQL DDL specifies the integrity constraint which makes sure that any changes made to the database don’t affect the consistency of data. • SQL DDL also maintains the set of indices for each relation which let you retrieve the records from the database quickly. • SQL DDL maintains the information about the security of data in the database and it also keeps the information regarding the authorization for each relation in the database. • SQL DDL also describes the storage structure of each relation on the hard disk.
  • 4.  Examples of DDL commands: • CREATE – is used to create the database or its objects (like table, index, function, views, store procedure and triggers). • DROP – is used to delete objects from the database. • ALTER-is used to alter the structure of the database. • TRUNCATE–is used to remove all records from a table, including all spaces allocated for the records are removed. • COMMENT –is used to add comments to the data dictionary. • RENAME –is used to rename an object existing in the database.
  • 5. 1. CREATE COMMAND • CREATE command is used for creating objects in the database. • It creates a new table.  Syntax: CREATE TABLE <table_name> ( column_name1 datatype, column_name2 datatype, . . . column_name_n datatype ); Example : CREATE command  CREATE TABLE employee ( empid INT, ename CHAR, age INT, city CHAR(25), phone_no VARCHAR(20) );
  • 6. 2. DROP COMMAND • DROP command allows to remove entire database objects from the database. • It removes entire data structure from the database. • It deletes a table, index or view.  Syntax: DROP TABLE <table_name>; OR DROP DATABASE <database_name>; Example : DROP Command  DROP TABLE employee; OR DROP DATABASE employees; • If you want to remove individual records, then use DELETE command of the DML statement.
  • 7. 3. ALTER COMMAND • An ALTER command allows to alter or modify the structure of the database. • It modifies an existing database object. • Using this command, you can add additional column, drop existing column and even change the data type of columns.  Syntax: ALTER TABLE <table_name> ADD <column_name datatype>; OR ALTER TABLE <table_name> CHANGE <old_column_name> <new_column_name>; OR ALTER TABLE <table_name> DROP COLUMN <column_name>; Example : ALTER Command ALTER TABLE employee ADD (address varchar2(50)); OR ALTER TABLE employee CHANGE (phone_no) (contact_no); OR ALTER TABLE employee DROP COLUMN age; To view the changed structure of table, use 'DESCRIBE' command. For example: DESCRIBE TABLE employee;
  • 8. 4. RENAME COMMAND • RENAME command is used to rename an object. • It renames a database table.  Syntax: RENAME TABLE <old_name> TO <new_name>; Example: RENAME TABLE emp TO employee;
  • 9. 5. TRUNCATE COMMAND • TRUNCATE command is used to delete all the rows from the table permanently. • It removes all the records from a table, including all spaces allocated for the records. • This command is same as DELETE command, but TRUNCATE command does not generate any rollback data.  Syntax: TRUNCATE TABLE <table_name>; Example: TRUNCATE TABLE employee;
  • 10. Queries  The SQL SELECT statement is used to fetch the data from a database table which returns this data in the form of a result table. These result tables are called result-sets.  Syntax If you want to fetch all the fields available in the field, then you can use the following syntax.
  • 11.
  • 12.
  • 13. where clause  The SQL WHERE clause is used to specify a condition while fetching the data from a single table or by joining with multiple tables. If the given condition is satisfied, then only it returns a specific value from the table. You should use the WHERE clause to filter the records and fetching only the necessary records.  The WHERE clause is not only used in the SELECT statement, but it is also used in the UPDATE, DELETE statement, etc., which we would examine in the subsequent chapters. 
  • 14.
  • 15.
  • 16. AND operator  The SQL AND & OR operators are used to combine multiple conditions to narrow data in an SQL statement. These two operators are called as the conjunctive operators.  These operators provide a means to make multiple comparisons with different operators in the same SQL statement.  The AND Operator  The AND operator allows the existence of multiple conditions in an SQL statement's WHERE clause.
  • 17.
  • 18. OR
  • 20.
  • 22. Delete statement  The SQL DELETE Query is used to delete the existing records from a table.  You can use the WHERE clause with a DELETE query to delete the selected rows, otherwise all the records would be deleted.
  • 23.
  • 24. View in SQL  view is nothing more than a SQL statement that is stored in the database with an associated name. A view is actually a composition of a table in the form of a predefined SQL query.  A view can contain all rows of a table or select rows from a table.  A view can be created from one or many tables which depends on the written SQL query to create a view.  Views, which are a type of virtual tables allow users to do the following − • Structure data in a way that users or classes of users find natural or intuitive. • Restrict access to the data in such a way that a user can see and (sometimes) modify exactly what they need and no more. • Summarize data from various tables which can be used to generate reports.
  • 26.
  • 27.
  • 28. General Constraints Constraints are the rules enforced on the data columns of a table. These are used to limit the type of data that can go into a table. This ensures the accuracy and reliability of the data in the database. Constraints could be either on a column level or a table level. The column level constraints are applied only to one column, whereas the table level constraints are applied to the whole table.
  • 29. Dropping Constraints  Any constraint that you have defined can be dropped using the ALTER TABLE command with the DROP CONSTRAINT option.  For example, to drop the primary key constraint in the EMPLOYEES table, you can use the following command.
  • 30. Indexes  Indexes are special lookup tables that the database search engine can use to speed up data retrieval.  Simply put, an index is a pointer to data in a table.  An index in a database is very similar to an index in the back of a book.  For example, if you want to reference all pages in a book that discusses a certain topic, you first refer to the index, which lists all the topics alphabetically and are then referred to one or more specific page numbers.  An index helps to speed up SELECT queries and WHERE clauses, but it slows down data input, with the UPDATE and the INSERT statements.  Indexes can be created or dropped with no effect on the data.
  • 31.
  • 32.
  • 33. Additional Features • SQL is easy to learn. • SQL is used to access data from relational database management systems. • SQL can execute queries against the database. • SQL is used to describe the data. • SQL is used to define the data in the database and manipulate it when needed. • SQL is used to create and drop the database and table. • SQL is used to create a view, stored procedure, function in a database. • SQL allows users to set permissions on tables, procedures, and views.
  • 34. Advantages of SQL  There are the following advantages of SQL:  High speed  Using the SQL queries, the user can quickly and efficiently retrieve a large amount of records from a database.  No coding needed  In the standard SQL, it is very easy to manage the database system. It doesn't require a substantial amount of code to manage the database system.  Well defined standards  Long established are used by the SQL databases that are being used by ISO and ANSI.  Portability  SQL can be used in laptop, PCs, server and even some mobile phones.  Interactive language  SQL is a domain language used to communicate with the database. It is also used to receive answers to the complex questions in seconds.  Multiple data view