Download presentation
Presentation is loading. Please wait.
1
Instructor: SAMIA ARSHAD
DDL COMMANDS Instructor: SAMIA ARSHAD
2
SQL Introduction Standard language for querying and manipulating data
Structured Query Language
3
SQL Data Definition Language (DDL) Data Manipulation Language (DML)
Create/alter/delete tables and their attributes Data Manipulation Language (DML) Query one or more tables . Insert/delete/modify tuples in tables.
4
Tables in SQL PName Price Category Manufacturer Hp tab 20,000 Gadgets
Table name Attribute names Product PName Price Category Manufacturer Hp tab 20,000 Gadgets Hp Ipad 40,000 Apple Brake fluid 3,800 Automobile Prestone Paint 800 Household Dulux Tuples or rows
5
Tables Explained The schema of a table is the table name and its attributes: Product(PName, Price, Category, Manfacturer) A key is an attribute whose values are unique; we underline a key
6
Data Types in SQL Atomic types:
Characters: CHAR(20), VARCHAR(50) Numbers: INT, BIGINT, SMALLINT, FLOAT Others: MONEY, DATETIME, … Every attribute must have an atomic type
7
DDL commands CREATE table: used to create a table
ALTER table: modifies a table after it was created. DROP table: removes a table from a database
8
CREATE TABLE CREATE TABLE employee (Employeeid INT,ENAME VARCHAR(50),
JOB VARCHAR(80)) SETTING PK (Employeeid INT PRIMARY KEY,ENAME VARCHAR(50), JOB VARCHAR(80)))
9
Alter ALTER TABLE statement is used to add, modify, or drop/delete columns in a table. To ADD A COLUMN in a table: ALTER TABLE employee ADD salary int(45);
10
ADD MULTIPLE COLUMNS IN TABLE
ALTER TABLE employee ADD (employee_firstname varchar(45), city varchar(40)); MODIFY COLUMN IN TABLE MODIFY CITY CHAR
11
DROP To delete a column in a table, use the following syntax.
ALTER TABLE table_name DROP COLUMN column_name ALTER TABLE employee DROP COLUMN city
12
DROP TABLE To delete a table from database. DROP TABLE table_name
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.