SHAHID NASIM RIYA.DBMS
SHAHID NASIM RIYA.DBMS
DEPARTMENT OF MATHEMATICS
CHANDIGARH UNIVERSITY
SUBMITTED BY:
NAME - SHAHID
SAJAD ,MD NASIM,RIYA
SUBMITTED TO :
UID –
24MSM40059,24MSM40068, SYYADA SHUMAILA
24MSM40072 ASSISTANT PROFESSOR
SQL workload database systems.
Structured Query Language’s
SQL, which stands for Structured programming provides
Querry Language, is a powerful and different ways to describe data
standardized programming language more analytically.
used for managing and manipulating
relational data. It allows user to 3. High Availability :-
interact with databases by defining, SQL is compatible with other
querying, updating, and databases such as Microsoft
manipulating data. SQL is a versatile SQL Server, Oracle Database,
language used in various database MS Access, MySQL, SAP
management system like MySQL,
Adaptive Server, and more.
Microsoft SQL Server, Oracle
Database SQLite etc. 4. High Security :- SQL
also has high security as one
Features
of its notable features. It’s
SQL has several features that makes easy to give permissions on
it a powerful and versatile language views, procedures, and tables.
for working with relational So with SQL, you get
databases. Some of the key features optimum security for your
of SQL are: data.
1. Flexibility and
Scalability :- SQL offers
users flexibility and 1. Open Source :-
scalability for relational
database management Structured Query Language
systems. With SQL, it is has the feature of being an
easier to create new tables open-source programming
while dropping or deleting language great for building
previously-created or scantily relational database
used tables. management systems
2. High Performanc :- (RDBMS). This makes it a
Another feature of SQL is that great pick for developers and
it offers a high-performance programmers who are looking
programming capability for for a community of
high usage, incredibly professionals to learn from
transactional, and heavy
off, and it’s also one of the
benefits of SQL.
1. Floating-Point Types :
Data
DATATYPES IN SQL To
Type From
In SQL (Structured Query Floa -
1.79E+308
Language), data types are used to t 1.79E+308
specify the types of that data can be Real -3.40E+38 3.40E+38
stored in a column of a database
table. Different database
management system (DBMS) may
have slightly different data types, 2. Character
but there are some common data Strings: CHAR(n) - The
types that are widely used. Here are maximum length of 8000
some of the most common data characters (Fixed-Length
types in SQL: non-Unicode Characters).
VARCHAR(n) - The
maximum length of 8000
1.Integer Type characters (Variable-
Length non-Unicode
Data From To Characters).
type
Big -263 (- 263 -1
Int 9,223,372,036,854,775, (9,223,372,036,854,775,
808) 807)
Int -231 (-2,147,483,648) 231-1 (2,147,483,647)
Sma -215 (-32,768) 215-1 (32,767)
ll int
SQL Commands
SQL commands are instructions. It is
used to communicate with the
database. It is also used to perform
specific tasks, functions, and queries DDL Commands
of data.SQL can perform various
The DDL Commands in Structured
tasks like create a table, add data to
Query Language are used to create
tables, drop the table, modify the
and modify the database schema and
table, set permission for users.
its objects. The syntax of DDL
Types of SQL Commands commands is predefined for
describing the data. The commands
There are five types of SQL of Data Definition Language deal
commands: with how the data should exist in the
1. DDL (Data Definition database.
Language) :- DDL changes
the structure of the table Following are the five
like creating a table, DDL commands in SQL:
1. CREATE Command Example :- Suppose, you want to
2. DROP Command create a Student table with five
3. ALTER Command columns in the SQL database. To do
4. TRUNCATE Command this, you have to write the following
5. RENAME Command DDL command:
1. CREATE TABLE Student
1. CREATE Command 2. (
CREATE is a DDL command to 3. Roll_ No. Int,
4. First_
create databases, tables, triggers, and
Name Varchar (20),
other objects.
5. Last
Syntax to Create a Database: _Name Varchar (20),
6. Age Int,
1. CREATE Database :- 7. Marks Int,
When want to create a 8. );
Books database in the SQL
database. To do this, you Output –
have to write the following
DDL Command
“Create Database Books”.
We can also add and drop table Suppose, you want to remove the
constraints using the ALTER Age and Marks column from the
command. existing Student table. To do this,
you have to write the following
Syntax to add a new field in the DDL command:
table: 1. ALTER TABLE Student
DROP Age;
1. ALTER TABLE name_ of_
OUTPUT –
table ADD column_
name column_ definition;
OUTPUT –
The above query successfully
removed all the records from the
student table. Let's verify it by using
the following SELECT statement:
1. SELECT * FROM Student;
5. RENAME
4. TRUNCATE
Command:
Command
RENAME is a DDL command used
TRUNCATE is another DDL
to change the name of the database
command that deletes or removes all
table.
the records from the table.
Syntax of RENAME command
This command also removes the
space allocated for storing the table
1. RENAME TABLE Old _
records.
Table_ Name TO New_
Syntax of TRUNCATE command Table_ Name;
1. RENAME TABLE Student TO
1. TRUNCATE TABLE Student_ Details ;
TABLE_ Name;
This query changes the
Suppose, you want to delete the name of the table from
record of the Student table. To do
Student to Student_ Syntax:
Details INSERT INTO table_
name (column_name_1,
column_name_2,
Output:- column_name_3, ...)
VALUES (value1,
value2, value3, ...)
Example:
INSERT INTO Student
(Roll_ No., First_ Name,
Last_ Name, Age, Marks)
VALUES (101,”
Ashutosh”,”
Semwal”,”23”,83);
DML Commands
DML or Data Manipulation
Language is the SQL command that Output –
deals with the manipulation of data
present in the database. We can
easily access, store, modify, update,
and delete the existing records from
the database using DML commands.
Some popularly known DDL
commands are: -
1. INSERT Command
INSERT is used to insert new
records into database tables. We can
insert data in all the columns of a
table or some specific columns using 2. SELECT Command
the INSERT command. While
inserting records, the user should SELECT is the most important data
check if there are any integrity manipulation command in
constraints like PRIMARY Structured Query Language. The
KEY, UNIQUE, NOT NULL, etc. SELECT command shows the
on the table and insert records records of the specified table.
accordingly.
Syntax: specify which records we want to
SELECT column_Na
update using
me_1, column_Nam the WHERE condition. WHERE
e_2, ….., column_Na is a clause in SQL that filters data
me_N FROM Name_ depending on the condition.
of_table; The UPDATE command can
SELECT * FROM update single or multiple records
table_ name; according to WHERE conditions.
Example:
SELECT First _
name, Last_ name Syntax:
FROM Student;
SELECT * FROM St UPDATE Table_nam
udent; e SET [column_nam
e1= value_1, ….., co
lumn_nameN = valu
e_N]
WHERE CONDITION
Output – ;
Example:
UPDATE Student SET
marks =
85 WHERE Roll_ No. =
101;
3. UPDATE Command
Example:
GRANT SELECT,
INSERT ON
employees TO
user1;
2. REVOKE
DCL Commands Command
DCL stands for Data Control The REVOKE command is used
Language. Data Control Language is to remove or revoke previously
a set of commands in SQL granted privileges from a user or a
(Structured Query Language) that group of users.
deals with the control and
management of access to data within Syntax:-
a database. DCL includes commands REVOKE privilege_
that define the permissions and name
privileges granted to database users. ON object_ name
Two primary commands within FROM {user_ name
DCL are GRANT and REVOKE. | PUBLIC | role_
name} [, ...];
Example:-
REVOKE INSERT
ON employees
FROM user1;