0% found this document useful (0 votes)
14 views

SHAHID NASIM RIYA.DBMS

The term paper discusses Structured Query Language (SQL) as a powerful programming language for managing and manipulating relational databases. It covers SQL features, data types, and various SQL commands categorized into Data Definition Language (DDL), Data Manipulation Language (DML), and Data Control Language (DCL). The paper provides examples of commands for creating, modifying, and deleting database objects, as well as managing user permissions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

SHAHID NASIM RIYA.DBMS

The term paper discusses Structured Query Language (SQL) as a powerful programming language for managing and manipulating relational databases. It covers SQL features, data types, and various SQL commands categorized into Data Definition Language (DDL), Data Manipulation Language (DML), and Data Control Language (DCL). The paper provides examples of commands for creating, modifying, and deleting database objects, as well as managing user permissions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

TERM PAPER ON SQL AND SQL COMMANDS

DATABASE MANAGEMENT SYSTEM

DEPARTMENT OF MATHEMATICS

CHANDIGARH UNIVERSITY

M.Sc. DATA SCIENCE – 1

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

TEXT - The maximum


length of 8000 characters
(Variable-Length non-
Unicode Characters).

3. Date and Time:


DATE - A data type is used deleting a table, altering a
to store the data of date in table, etc.
a record. 2. DML (Data Manipulation
TIME - A data type is used Language) :- DML
to store the data of time in commands are used to
a record modify the database. It is
DATETIME - A data type responsible for all form of
is used to store both the changes in the database.
data, date, and time in the 3. DCL (Data Control
record. Language) :- DCL
commands are used to
4. Boolean: grant and take back
This data type is used to authority from any
store logical values. The database user.
only possible values are
TRUE and FALSE.

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”.

Syntax to create a new table:


1. CREATE TABLE 2. DROP Command
TABLE_ NAME
2. ( DROP is a DDL command used to
3. column_Name1 data delete/remove the database objects
_type (size of the column ), from the SQL database. We can
easily remove the entire table, view,
4. column_Name2 data_ or index from the database using this
type (size of the column), DDL command.
5. column_Name3 data_
Syntax to remove a database:
type (size of the column),
1. DROP DATABASE Database
6. ...
7. column_ NameN data_ _ Name;
type (size of the column )
Suppose, you want to delete the
8. ); Books database from the SQL
database. To do this, you have to 1. ALTER TABLE Student ADD
write the following DDL command: Father's_ Name Varchar(60);
1. DROP DATABASE Books;
OUTPUT –
OUTPUT -

Syntax to remove a column from


the table:

1. ALTER TABLE name_


of_table DROP Column_
3. ALTER Command
ALTER is a DDL command that
changes or modifies the existing
structure of the database, and it also Name_1 , column_Name
changes the schema of database _2 , ….., column_Name_
objects. N;

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;

Suppose, you want to add the


'Father's_ Name' column in the
Student table. To do this, you have
to write the following DDL
command:
Syntax to modify the column of
the table:
1. ALTER TABLE table_name M this, you have to write the following
ODIFY ( column_name column TRUNCATE DDL command:
_datatype(size)); 1. TRUNCATE TABLE Student;

Suppose, you want to change the OUTPUT –


character size of the Last Namefield
of the Student table. To do this, you
have to write the following DDL
command:
1. ALTER TABLE table_ Nothing will change here because there
name MODIFY ( Last_ is no data in the table.
Name varchar(25));

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

UPDATE is a DML command in


SQL used to update existing OUTPUT :-
records in the table. We must

4. DELETE Command DELETE is a DML command


used to delete existing records
from the table. This command is
used to delete single or multiple 1. GRANT Command
records from the tables based on
the condition given in The GRANT command is used to
the WHERE clause. provide specific privileges or
permissions to database users. These
Syntax: privileges might include the ability
 DELETE FROM Tabl to execute certain types of SQL
e_ statements (e.g., SELECT, INSERT,
Name WHERE condi UPDATE, DELETE) on specific
tion; database objects
Example :
Syntax:
 DELETE FROM Stud  GRANT privilege_
ent WHERE Roll_ name
No. = 101;  ON object_ name
 TO {user_ name |
PUBLIC | role_
name} [, ...]
 [WITH GRANT
Output – OPTION];

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;

These commands play a crucial role


in database security and access
control. By using DCL statements,
database administrators can define
who has access to what data and
what operations they can perform.
This helps in ensuring data integrity,
confidentiality, and proper
management of the database.
Additionally, roles can be used in
conjunction with DCL commands.
Roles are named groups of related
privileges that can be assigned to
users. This simplifies the process of
managing permissions by allowing
the assignment of roles to users, and
then granting or revoking privileges
from those roles.

You might also like