Dbms Practical Print
Dbms Practical Print
Dbms Practical Print
AND TECHNOLOGY
DATABASE MANAGEMENT
SYSTEM
NAME: SUNIDHI
ENROLLMENT NO.: A2305218584
SECTION: 4CSE 9Y
INTRODUCTION TO SQL
SQL is a standard language for accessing and manipulating databases. SQL stands for
Structured Query Language. SQL is used to communicate with a database. According to
ANSI (American National Standards Institute), it is the standard language for relational
database management systems. SQL statements are used to perform tasks such as update data
on a database, or retrieve data from a database.
Some common relational database management systems that use SQL are: Oracle, Sybase,
Microsoft SQL Server, Access, Ingres, etc. Although most database systems use SQL, most
of them also have their own additional proprietary extensions that are usually only used on
their system.
However, the standard SQL commands such as "Select", "Insert", "Update", "Delete",
"Create", and "Drop" can be used to accomplish almost everything that one needs to do with
a database.
FUNCTIONS OF SQL
1. SQL can execute queries against a database
2. SQL can retrieve data from a database
3. SQL can insert records in a database
4. SQL can update records in a database
5. SQL can delete records from a database
6. SQL can create new databases
7. SQL can create new tables in a database
8. SQL can create stored procedures in a database
9. SQL can create views in a database
10. SQL can set permissions on tables, procedures, and views
HOW IT WORKS?
A relational database system contains one or more objects called tables. The data or
information for the database are stored in these tables. Tables are uniquely identified by their
names and are comprised of columns and rows. Columns contain the column name, data type,
and any other attributes for the column. Rows contain the records or data for the columns.
APPLICATIONS OF SQL
As mentioned before, SQL is one of the most widely used query language over the
databases. I'm going to list few of them here:
1. Allows users to access data in the relational database management systems.
2. Allows users to describe the data.
3. Allows users to define the data in a database and manipulate that data.
4. Allows to embed within other languages using SQL modules, libraries & pre-
compilers.
5. Allows users to create and drop databases and tables.
6. Allows users to create view, stored procedure, functions in a database.
7. Allows users to set permissions on tables, procedures and views.
SQL PROCESS
When you are executing an SQL command for any RDBMS, the system determines the best
way to carry out your request and SQL engine figures out how to interpret the task. There are
various components included in this process.
These components are −
1. Query Dispatcher
2. Optimization Engines
3. Classic Query Engine
4. SQL Query Engine, etc.
A classic query engine handles all the non-SQL queries, but a SQL query engine won't handle
logical files.
Following is a simple diagram showing the SQL Architecture –
SQL ARCHITECTURE
PRACTICAL 1
AIM :- To study DDL commands
CREATE :- We can use below command to create a database on a SQL Server instance. To
create a database, we must be logged in to the server and have appropriate permissions
(CREATE DATABASE, CREATE ANY DATABASE, or ALTER ANY DATABASE).
Syntax: CREATE DATABASE <database-name>
where <database-name> is the name of the database to be created
ALTER :- We can change the settings of created database using ALTER DATABASE
command. For example, to modify the file name (data or log file), follow below syntax;
Syntax: ALTER DATABASE <database-name>
MODIFY FILE (NAME = <old file name>,NEWNAME = <new file name>)
3. Rename a column :-
Syntax: ALTER TABLE <table name> rename column <old column name>
to <new column name>
DROP :- To drop something from the table or to delete something from the
Table.
2. Drop table
To drop a table, follow below syntax;
Syntax: DROP TABLE <schema-name>.<table-name>
DESCRIBE Student_details
Data Manipulation Language (DML) statements or commands are used for managing data
within tables. Some commands of DML are:
Some commands of DML are:
1. SELECT – retrieve data from the a database
2. INSERT – insert data into a table
3. UPDATE – updates existing data within a table
4. DELETE – deletes all records from a table, the space for the records remain
INSERT :
The insert statement is used to add new row to a table.
Syntax: INSERT INTO <table name> VALUES (<value 1>, ... <value n>)
The inserted values must match the table structure exactly in the number of attributes and the
data type of each attribute. Character type values are always enclosed in single quotes;
number values are never in quotes; date values are often (but not always) in the format ‘yyyy-
mm-dd’ (for example, ‘2006-11- 30’).
UPDATE :
The update statement is used to change values that are already in a table.
DELETE :
The delete statement deletes row(s) from a table.
SELECT :
The SELECT statement is used to form queries for extracting information out of the database.
To select the entire table use *.
Syntax:
For columns: SELECT <attribute>, ….., <attribute n> FROM <table name>
For entire table: SELECT * FROM <table name>
EXECUTION CODE:
CREATE TABLE Student_details
(name varchar(20), course varchar(50), roll_no int, sec varchar(5),address varchar(50),
semester int
)
UPDATE student_details
SET roll_no = 8578
WHERE name ='VARSHA'