0% found this document useful (0 votes)
41 views5 pages

Fundamenatal Database

Uploaded by

hawariya abel
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)
41 views5 pages

Fundamenatal Database

Uploaded by

hawariya abel
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/ 5

fundamental DATABASE SYSTEM lab course

DDL (DATA DEFINITION COMMANDS)

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 is a set of SQL
commands used to create, modify, and delete database structures but not data. These
commands are normally not used by a general user, who should be accessing the database via
an application.
List of DDL commands:

 CREATE: This command is used to create the database or its objects (like table, index,
function, views, store procedure, and triggers).
SQL COMMAND
 DEFINING DATABSE
CREATE DATABASE SUMMER_STUDENT;
 DEFINING TABLE
CREATE TABLE IT
(
ID VARCHAR (25) PRIMARY KEY NOT NULL,
FIRST_NAME VARCHAR (30) NOT NULL,
LAST_NAME VARCHAR (30) NOT NULL,
SEX CHAR (6) NOT NULL,
SECTION INT NOT NULL
);
 DROP: This command is used to delete objects from the database.
SQL COMMAND
 REMOVING DATABASE
DROP DATABASE DATABSE NAME;
Ex. DROP DATABSE SUMMER_STUDENT;
 REMOVING TABLE
DROP TABLE TABLE NAME;
Ex. DROP TABLE IT;

compiled by ZEKARIAS BIRBIRSA @ wsu 2022 1


fundamental DATABASE SYSTEM lab course

 ALTER: This is used to alter the structure of the database.


SQL COMMAND
 MODIFIYING THE STRUCTURE OF TABLE BY ADDING COLUMN
ALTER TABLE TABLE_NAME ADD COLUMN_NAME datatype;

Ex. ALTER TABLE IT ADD AGE INT;


 MODIFIYING THE STRUCTURE OF TABLE BY REMOVING
COLUMN
ALTER TABLE TABLE_NAMEDROP COLUMN COLUMN_NAME;

EX. ALTER TABLE IT DROP COLUMN SECTION;

 TRUNCATE: This is used to remove all records from a table, including all spaces
allocated for the records are removed.
SQL COMMAND
TRUNCATE TABLE TABLE_NAME;
EX. TRUNCATE TABLE IT;
 COMMENT: This is used to add comments to the data dictionary.
 RENAME: This is used to rename an object existing in the database.
DML (DATA MANIPULATION LANGUAGE)
The SQL commands that deal with the manipulation of data present in the database belong to
DML or Data Manipulation Language and this includes most of the SQL statements. It is the
component of the SQL statement that controls access to data and to the database. Basically,
DCL statements are grouped with DML statements.

List of DML commands:

 INSERT: It is used to insert data into a table.


SQL COMMAND
INSERT INTO TABLE_NAME VALUES (VALUE1, VALUE2, VALUE3....);
INSERT INTO IT VALUES('SOI/SUMMER/100/12','DANIEL','TASEW','MALE','34','3');
INSERT INTO IT VALUES('SOI/SUMMER/101/12','HIRUT','MELKAMU','FEMALE','32','3')
INSERT INTO IT VALUES('SOI/SUMMER/102/12','HANA','SAMUEL','FEMALE','24','3')

compiled by ZEKARIAS BIRBIRSA @ wsu 2022 2


fundamental DATABASE SYSTEM lab course

INSERT INTO IT VALUES('SOI/SUMMER/103/12','ZINAW','TEMESGEN','MALE','23','3')


INSERT INTO IT VALUES('SOI/SUMMER/104/12','DAGIM','BEKELE','MALE','43','3')
 UPDATE: It is used to update existing data within a table.
SQL COMMAND
UPDATE TABLE_NAME SET COLUMN1=VALUE, COLUMN2=VALUE… WHERE
SOME_COLUMN=SOME_VALUE;
EX. UPDATE IT SET SECTION=4 WHERE ID=’SOI/SUMMER/102/12’
 DELETE: It is used to delete records from a database table.
SQL COMMAND
DELETE FROM TABLE_NAMEWHERE SOME_COLUMN=SOME_VALUE;

EX. DELETE FROM IT WHERE ID=’SOI/SUMMER/102/12’;


DQL (DATA QUERY LANGUAGE):
DQL statements are used for performing queries on the data within schema objects. The
purpose of the DQL Command is to get some schema relation based on the query passed to
it. We can define DQL as follows it is a component of SQL statement that allows getting data
from the database and imposing order upon it. It includes the SELECT statement. This
command allows getting the data out of the database to perform operations with it. When a
SELECT is fired against a table or tables the result is compiled into a further temporary table,
which is displayed or perhaps received by the program i.e., a front-end.
List of DQL commands

 SELECT: It is used to retrieve data from the database.


SQL COMMAND
SELECT *FROM TABLE_NAME;
EX. SELECT * FROM IT
SELECT COLUMN_NAME1, COLUMN_NAME2…FROM TABLE_NAME;
EX. SELECT ID, FIRST_NAME, LAST_NAME, SECTION FROM IT;
DCL (Data Control Language):
DCL includes commands such as GRANT and REVOKE which mainly deal with the rights,
permissions, and other controls of the database system.

List of DCL commands:


compiled by ZEKARIAS BIRBIRSA @ wsu 2022 3
fundamental DATABASE SYSTEM lab course

 GRANT: This command gives users access privileges to the database.


 REVOKE: This command withdraws the user’s access privileges given by using the
GRANT command.
TCL(TRANSACTION CONTROL LANGUAGE)
Though many resources claim there to be another category of SQL clauses TCL – Transaction
Control Language. So, we will see in detail about TCL as well. TCL commands deal with
the transaction within the database .
List of TCL commands:

 COMMIT: Commits a Transaction.


 ROLLBACK: Rollbacks a transaction in case of any error occurs.
 SAVE POINT: Sets a save point within a transaction.
 SET TRANSACTION: Specify characteristics for the transaction.
 SQL ON MYSQL WORKBENCH
 create database summer_student
 use summer_student

create table it

id varchar (25) primary key not null,

first_name varchar (30) not null,

Last_name varchar (30) not null,

sex char (6) not null,

section int not null

 alter table it add age int;


 alter table it drop column section;
 insert into it values('soi/summer/100/12','daniel','tasew','male','34','3')

compiled by ZEKARIAS BIRBIRSA @ wsu 2022 4


fundamental DATABASE SYSTEM lab course

 truncate table it;


 insert into it values('soi/summer/101/12','hirut','melkamu','female','32','3')
 insert into it values('soi/summer/102/12','hana','samuel','female','24','3')
 insert into it values('soi/summer/103/12','zinaw','temesgen','male','23','3')
 insert into it values('soi/summer/104/12','dagim','bekele','male','43','3')
 insert into it values('soi/summer/105/12','motolomi','loha','male','33','3')
 select id, FIRST_NAME, LAST_NAME, section from it
 update it set section=4 where id= 'soi/summer/102/12'
 delete from it where id ='soi/summer/102/12'

compiled by ZEKARIAS BIRBIRSA @ wsu 2022 5

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy