logo

Structured Query Language - PDF

9 Pages1603 Words187 Views
   

Added on  2021-08-16

Structured Query Language - PDF

   Added on 2021-08-16

ShareRelated Documents
Name: Rijna Shrestha
Roll No.: 36
1.Short note on DDL and DML:
Structured Query Language (SQL) is the database language by the use of
which we can perform certain operations on the existing database and also we
can use this language to create a database. SQL uses certain commands like
Create, Drop, Insert etc. to carry out the required tasks. Once data is stored, it
often needs to be modified. Data is inserted, updated and deleted. Commands
that create objects like tables are called SQL DDL commands. On the other hand,
commands that modify data are called SQL DML commands.
These SQL commands are mainly categorized into four categories DDL, DML, DCL
&TCL:
DDL:
DDL (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 database.
Examples of DDL commands:
oCREATE – is used to create the database or its objects (like table,
index, function, views, store procedure and triggers).
oDROP – is used to delete objects from the database.
oALTER-is used to alter the structure of the database.
oTRUNCATE–is used to remove all records from a table, including all
spaces allocated for the records are removed.
oCOMMENT –is used to add comments to the data dictionary.
oRENAME –is used to rename an object existing in the database.
Structured Query Language - PDF_1
Query for DDL:
oCreate table: CREATE TABLE Tblscript
(
ID int not null identity(1,1),
Name varchar(50),
Address varchar(50),
Qualification varchar(50),
Age int,
Gender char(50),
)
oAlter table: ALTER TABLE Tblscript
ADD DOB date;
oCreate View: SELECT * FROM Tblscript
DML:
The SQL commands that deals with the manipulation of data present in database
belong to DML or Data Manipulation Language and this includes most of the SQL
statements.
Examples of DML:
SELECT – is used to retrieve data from a database.
INSERT – is used to insert data into a table.
UPDATE – is used to update existing data within a table.
DELETE – is used to delete records from a database table.
Structured Query Language - PDF_2
Query of DML:
oInsert into table: INSERT INTO Tblscript
values ('Rita','Pokhara','SEE/10','16','Female')
INSERT INTO Tblscript
(Name,Address,Age,Gender)
values ('Sijal','Kathmandu','20','Male')
oUpdate table: select Name from Tblscript
update Tblscript set name='Jerry'
where name='Sijal'
2. Calculated Field:
A calculated field is a field for querying or outputting information that cannot
be directly queried or output from a database table. A computed column is a
virtual column that is not physically stored in the table, unless the column is
marked PERSISTED. A computed column expression can use data from other
columns to calculate a value for the column to which it belongs. The ability to
manipulate field values in query results without altering the data in the
database itself provides many significant benefits. A calculated field either
performs some calculation on database fields to create a value that is not
stored in the database or selects the value from a particular database field
based on customized criteria.
Some examples include:
1. Data can be stored with the appropriate data type
2. Formatting/conversion is generally faster through the RDBMS in
comparison to the application layer (i.e. PHP, Python)
Structured Query Language - PDF_3

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
Data Modelling & SQL Language : Assignment
|21
|2425
|31

Database Queries
|15
|2102
|407

Different Database Models Assignment
|11
|1627
|160

Systems Analysis and Database Design: Quiz 3
|5
|1091
|43

STUDENT NAME:. 11 October 2016. SQL HW #3: DDL and DML
|4
|398
|232

SQL: DDL Create and Alter, DCL Grant and Revoke, Data Manipulation, Database Testing
|13
|2239
|63