Wednesday, November 11, 2009

Manipulating Data using DML

Data Manipulation Language :
A DML statement is executed when you :
  • Add new rows to a table
  • Modify existing rows in a table
  • Remove existing rows from a table
  • A transaction consists of a collection of DML statements that form a logical unit of work.

INSERT Statement Syntax :
Add new rows to a table by using the INSERT statement :
  • INSERT INTO table [(column [, column...])] VALUES (value [, value...])[,(value [,value..])];
  • With this syntax, only multiple rows are inserted at a time.
Inserting New Rows :
  • Insert a new row containing values for each column.
  • List values in the default order of the columns in the table.
  • Optionally, list the columns in the INSERT clause.
  • Enclose character and date values in single quotation marks.
  • INSERT INTO dept(deptno, dname, loc) VALUES (50, 'Public Relations',’EDMONTON’);
Inserting Rows with Null Values :
Implicit method :
  • Omit the column from the column list.
  • INSERT INTO dept (deptno, dname ) VALUES (60, 'Purchasing');
Explicit method :
  • Specify the NULL keyword in the VALUES clause.
  • INSERT INTO dept VALUES (70, 'Finance', NULL);

No comments:

Post a Comment

Followers