Contents
1. SQL data type

2. Data Definition Language(DDL)
3. Data Manipulation Language(DML)
4. Data Control Language(DCL)
1. SQL data type
1. SQL
▪ Structured Query Language(SQL) was designed by IBM to
create a standardize structure for interrogating and updating
databases.
▪ High-level language: “what to do” rather than “how to do it.”
- Avoid a lot of data-manipulation details needed in
procedural languages like c++ or java.
1. SQL data type
1. SQL
◆ SQL data types (from Oracle 9i):
▪ String types
Char(n) – fixed-length character data, n characters long maximum length
= 2000 bytes
Varchar2(n) – variable length character data, maximum 4000 bytes
Long – variable-length character data, up to 4gb. Maximum 1 per table

▪ Numeric types
Number(p,q) – general purpose numeric data type
Integer(p) – signed integer, p digits wide
Float(p) – floating point in scientific notation with p binary digits precision

▪ Data/Time types
Date – fixed-length date/time in dd-mm-yy form
2. Data Definition Language(DDL)
◆ Characteristic:
▪ Allows the dba or user to describe and name entities, attributes.
▪ Relationships required for the application and any associated
integrity and security constraints.
▪ Commands define a database, including
creating, altering, dropping tables and establishing constraints.
2. Data Definition Language(DDL)
◆ Characteristic:
▪ Create a table
Create table [table name] ( columnname datatype, ...);
For example:
Create table customers ( col1 number, col2 varchar2(20));
▪ Rename a table
Alter table [table name] rename to [new table name];
For example:
Alter table customers rename to customer;
▪ Add a column
Alter table [table name] add ( [column name] [datatype], ... );
For example:
Alter table employee add (id int);
2. Data Definition Language(DDL)
◆ Characteristic:
▪ Modify a column
Alter table [table name] modify ( [column] [new data type] );
For example:
Alter table employee modify( sickhours float );
▪ Drop a column
Alter table [table name] drop column [column name];
For example:
Alter table employee drop column vacationpay;
▪ Removing tables
Drop table statement allows you to remove tables from your
schema:
Drop table employee

1 ddl

  • 1.
    Contents 1. SQL datatype 2. Data Definition Language(DDL) 3. Data Manipulation Language(DML) 4. Data Control Language(DCL)
  • 2.
    1. SQL datatype 1. SQL ▪ Structured Query Language(SQL) was designed by IBM to create a standardize structure for interrogating and updating databases. ▪ High-level language: “what to do” rather than “how to do it.” - Avoid a lot of data-manipulation details needed in procedural languages like c++ or java.
  • 3.
    1. SQL datatype 1. SQL ◆ SQL data types (from Oracle 9i): ▪ String types Char(n) – fixed-length character data, n characters long maximum length = 2000 bytes Varchar2(n) – variable length character data, maximum 4000 bytes Long – variable-length character data, up to 4gb. Maximum 1 per table ▪ Numeric types Number(p,q) – general purpose numeric data type Integer(p) – signed integer, p digits wide Float(p) – floating point in scientific notation with p binary digits precision ▪ Data/Time types Date – fixed-length date/time in dd-mm-yy form
  • 4.
    2. Data DefinitionLanguage(DDL) ◆ Characteristic: ▪ Allows the dba or user to describe and name entities, attributes. ▪ Relationships required for the application and any associated integrity and security constraints. ▪ Commands define a database, including creating, altering, dropping tables and establishing constraints.
  • 5.
    2. Data DefinitionLanguage(DDL) ◆ Characteristic: ▪ Create a table Create table [table name] ( columnname datatype, ...); For example: Create table customers ( col1 number, col2 varchar2(20)); ▪ Rename a table Alter table [table name] rename to [new table name]; For example: Alter table customers rename to customer; ▪ Add a column Alter table [table name] add ( [column name] [datatype], ... ); For example: Alter table employee add (id int);
  • 6.
    2. Data DefinitionLanguage(DDL) ◆ Characteristic: ▪ Modify a column Alter table [table name] modify ( [column] [new data type] ); For example: Alter table employee modify( sickhours float ); ▪ Drop a column Alter table [table name] drop column [column name]; For example: Alter table employee drop column vacationpay; ▪ Removing tables Drop table statement allows you to remove tables from your schema: Drop table employee