Sie sind auf Seite 1von 4

Data Definition Language (DDL):

 CREATE : To Create Objects in Database


 ALTER : Alter the Structure of Database
 DROP : Delete Object From Database
 TRUNCATE: Remove all records from the table, including all spaces allocated
for the records are also removed.
 COMMENT : Add Comments to Data Dictionary

Data Manipulation Language (DML) :


 INSERT : Insert Data into Table
 UPDATE : Updates existing data within a table
 DELETE : Delete all records from a table, the space for records remains intact
 *CALL : Call a PL/SQL or Java subprogram
 *EXPLAIN PLAN : Explain access path to Data
 *LOCK : TABLE Control Concurrency

*Data Control Language (DCL):


 COMMIT : Save Work Done
 SAVEPOINT : Identify a point in a transaction to which you can later roll back
 ROLLBACK :Restore database to original since the last COMMIT
 SET TRANSACTION : Change transaction option like what rollback segment to
use
 GRANT : Grant permission to oracle user
 REVOKE : Take permission back from oracle user

Data Query Language (DQL):


 SELECT: Retrieve data from the database using SELECT statement.

* Not in Syllabus

Create Table:
Create table command defines each column of the table uniquely. Each column has
minimum of three attributes a name, data type and size. Each table

Rules for creating table:


1. A name can have maximum upto 30 characters.
2. Alphabets from A-Z , a-z and numbers from 0-9 are allowed
3. A name should begin with an alphabet
4. The use of special character like _ (underscore) is allowed and also
recommended.
5. SQL reserved words are not allowed. For Example : create, select and so on.

Syntax:
CREATE TABLE <tableName> (<columnName1> <DataType (<size>),
<columnName2> <DataType (<size>));

Example
CREATE TABLE bcom4 (rollno number(4), name varchar2(30), marks number(3));

Above example create a table with 3 fields (columns) rollno, name and marks. Currently
there is no data inside this table. Create table only create the structure of table.

Rollno Name Marks

In a table each field has data type such as


“rollno” has datatype number ,
“name” has datatype varchar2 and
“marks” has number datatype.

DML Commands :

Insert:
When a table is created for the very first time it is an empty structure. The next
thing to do is to load this empty structure with business data to be manipulated
later.
Loading table data can be done using the SQL INSERT statement which:
 Creates a new empty row in the database table
 Loads the values embedded within the SQL Insert statement into the
empty row

The following is the syntax for inserting the data or value into the table.
Syntax:
INSERT INTO <TableName> (<ColumnName1>, <ColumnName2>)
VALUES (<Expression1>, <Expression2>);

Character expressions used within the INSERT INTO statement must be enclosed in single


quotes (').
Table columns and values are related in any INSERT INTO SQL statement. The first value
specified is inserted into the first column, the second value is inserted in the second
column and so on.
Hence, in an INSERT INTO SQL sentence if there are exactly the same numbers of values
as there are columns and the values are sequenced exactly in accordance with the table
columns, there is no need to specify column names.
However, if there are lesser values specified in the INSERT INTO SQL statement than
there are columns in the table, then it is mandatory to indicate both the table column
name and its corresponding value in the INSERT INTO SQL sentence.
In the absence of a specific map between table column names and values the SQL engine
will insert data linearly, as it always does. Thus it’s quite possible that the wrong data
will be inserted into the wrong column and the table data would lose its integrity.

Update:
The UPDATE command is used to change or modify data values in a table.
The UPDATE verb in SQL is used to either update:
 All the rows in a table
OR
 A specific set of rows in a table

Updating All Rows


The UPDATE statement updates all the columns specified, in all the rows that exist in
the table. The SET clause indicates which column data should be modified and the new
values that they should hold. The WHERE clause, if given, defines particular rows that
should be updated. Otherwise, all table rows are updated.
The following is the syntax for updating all rows of data in the table. 
Syntax: 
Update <TableName>
SET <ColumnName1>=<Expression1>, <ColumnName2>=<Expression2>;

Update Specific Row(s)

The following is the syntax for updating specific row of data in the table. 

Syntax: 
Update <TableName>
SET <ColumnName1>=<Expression1>, <ColumnName2>=<Expression2>
WHERE <Condition>;

Delete:

The DELETE command deletes rows from the table that satisfies the condition
specified in its WHERE clause and returns the number of records deleted. 
If a DELETE statement without a WHERE clause is fired then all rows in the
table are deleted.

The verb DELETE in SQL is used to remove either:

 A set of rows from a table

OR

 All the rows from a table

Delete Specific Row(s)

The following is the syntax for deleting specific rows from the table. 
Syntax: 
DELETE FROM <TableName> WHERE <Condition>;

Delete:

The DELETE command deletes rows from the table that satisfies the condition
specified in its WHERE clause and returns the number of records deleted. 
If a DELETE statement without a WHERE clause is fired then all rows in the
table are deleted.

The verb DELETE in SQL is used to remove either:

 A set of rows from a table

OR

 All the rows from a table

Delete Specific Row(s)


The following is the syntax for deleting specific rows from the table. 
Syntax: 
DELETE FROM <TableName> WHERE <Condition>;

Das könnte Ihnen auch gefallen