0% found this document useful (0 votes)
31 views31 pages

It Specialist Database Database Management Using DDL

The document discusses various SQL commands used for database management. It covers: 1. Data Definition Language (DDL) commands like CREATE, ALTER, and DROP for tables, views, and stored procedures. 2. Clustered and non-clustered indexes and how they organize data physically. 3. SQL commands like SELECT, DISTINCT, COUNT, WHERE, IN, NOT IN, and ORDER BY for querying and filtering data. Examples are given for each command.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views31 pages

It Specialist Database Database Management Using DDL

The document discusses various SQL commands used for database management. It covers: 1. Data Definition Language (DDL) commands like CREATE, ALTER, and DROP for tables, views, and stored procedures. 2. Clustered and non-clustered indexes and how they organize data physically. 3. SQL commands like SELECT, DISTINCT, COUNT, WHERE, IN, NOT IN, and ORDER BY for querying and filtering data. Examples are given for each command.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

IT SPECIALIST

DATABASE
DATABASE MANAGEMENT
OBJECT USING DDL

Independent Study Pathway Data Analyst

Let’s Roll
Our Team

Ketut Susilo
Marketing

Aliyah Qulbinisa S Audrey Regina Cahyani Flora Anggur Adea M

Rahma Aulia Futri Soffi Amalia Nur Kholifah


TABLE OF CONTENTS

Data Definition
01 04 Stored Procedures
Language (DDL)

Create, alter, and Cluster and Non-


02 05 Cluster Index
drop table

Create, alter, and SQL Command :


03 07
06
drop views SELECT, COUNT IN,
08 WHERE, ORDER BY
Start Slide
01 DATA
DEFINITION
LANGUAGE
(DDL)
DDL IN DATABASE

A Data Definition Language (DDL) is a computer-


based language employed for crafting and altering
the arrangement of database elements within a
database, encompassing items such as views,
schemas, tables, indexes, and more.
DDL COMMAND
CREATE : to create a database and its
objects like (table, index, views, store
procedure, function, and triggers)
ALTER : Alters the structure of an existing
database.
DROP : Delete objects stored within the
database.
TRUNCATE : Clears all records from a
table, including the allocated storage
space for these records.
02 CREATE,
ALTER, AND
DROP TABLE
CREATE TABLE

The CREATE TABLE command creates


a new table in the database.
The following SQL creates a table
called "Persons" that contains five
columns: PersonID, LastName,
FirstName, Address, and City:
ALTER TABLE
Adds an "Email" column to the "Customers"
table:

The ALTER TABLE command adds,


deletes, or modifies columns in a table.
The ALTER TABLE command also adds
and deletes various constraints in a
table. Deletes the "Email" column from the
"Customers" table:
DROP TABLE

The DROP TABLE command deletes a


table in the database.
The following SQL deletes the table
"Shippers":
03 CREATE,
ALTER, AND
DROP VIEW
VIEW
A view can be described as a 'virtual representation
of data.' It can either be derived from another table or
formed by merging multiple tables.

A view can be useful in certain situations, such as :


1. To simplify the complexity of a query.
2. Grant a permission to users that contains.
specific data that the users are authorized to see
3. View can maintain consistency in the data if the
original table changes.
CREATE VIEW
INPUT

Create is a command to - to create a RESULT


database and its objects like (table,
index, views, store procedure, function,
and triggers).

To create view, then we use CREATE


VIEW statement. In this case, we try to
create film_info view : OUTPUT
ALTER VIEW
INPUT

RESULT
ALTER is a command to alters the
structure of the existing database
objects, such as rename, add data, etc.
To rename the film_info to
film_information table, then we use
ALTER VIEW statement.

In this case, we try to rename the


film_info view table to film_information OUTPUT
view table.
DROP VIEW
INPUT

Drop is a command to delete objects RESULT


from the database. To drop the
film_information view, then we use
DROP VIEW statement.

In this case, we try to drop or delete the


film_information view table.
OUTPUT
04 STORED
PROCEDURES
Stored Procedure is a function containing reusable SQL code. In a
Stored Procedure, parameters can also be entered so that the function
can be used more dynamically based on these parameters.Create a
Stored Procedure selectStudent() to get all NIM and NAM students
To call Stored Procedure selectStudent()
CALL selectStudent()

input output
jgf

select table with stored prosedure


Select student addresses in the Bandung area using a
stored procedure.So, every time we want to display a
student's NIM and NAME, we don't need to create SQL code
as usual. Just save the SQL code in a Stored Procedure and
we can call and use it over and over again

input output
insert record table with stored prosedure

If you want to insert student data into the


student table, you don't need to create the
INSERT code many times. We can use the
Stored Procedure insertStudent() to replace
the INSERT process that we usually use output
input
05 CLUSTER AND
NON-CLUSTER
INDEX
CLUSTER INDEX
________________________
A clustered index defines the order in
which data is physically stored in a
table.

Only one clustered index per table.

When a table has a clustered index,


the table is called a clustered table.
NON-CLUSTER INDEX
_______________________________

A non-clustered index doesn’t


sort the physical data inside
the table

A non-clustered index is stored


at one place and table data is
stored in another place.
06
SQL Command:
SELECT, DISTINCT,
COUNT, IN, NOT IN,
WHERE, ORDER BY
INPUT
Query SELECT

The SELECT statement is used to select


data from a database. The data
returned is stored in a result table,
called the result-set. OUTPUT

In this case, we try to use the select


statement to return the title,
release_year, and description of all
films.
Query SELECT
INPUT

DISTINCT
The DISTINCT clause is used in the
OUTPUT
SELECT statement to remove duplicate
rows from a result set.

The DISTINCT clause keeps one row for


each group of duplicates. The DISTINCT
clause can be applied to one or more
columns in the select list of the SELECT
statement.
Query COUNT
INPUT

DISTINCT
The COUNT DISTINCT function returns
OUTPUT
the number of unique values in the
column or expression.
INPUT
Query WHERE

The WHERE clause is used to filter


records. It is used to extract only those
records that fulfill a specified condition.
OUTPUT
In this case, we try to use the WHERE
clause for customers whose first names
are Adam.
INPUT
Query IN

The IN operator allows you to specify


multiple values in a WHERE clause.

In this case, suppose you want to know OUTPUT


the rental information of customer id 1
and 2, you can use the IN operator in
the WHERE clause as follows.
INPUT
Query NOT IN

NOT IN() makes sure that the expression


proceeded does not have any of the
values present in the arguments.
OUTPUT
The following statement finds all rentals
with the customer id is not 1 or 2.
INPUT
Query ORDER BY

The ORDER BY keyword is used to sort


the result-set in ascending or
descending order.
OUTPUT
The ORDER BY keyword sorts the
records in ascending order by default.
To sort the records in descending order,
use the DESC keyword.

The following statement selects email


and last name from the customer table
and sorts the rows by the email in
ascending order and last name in
descending order
THANK YOU

End Slide

You might also like