1.DDL (data retrival language)
*select
2.DML (data mnupulation language)
*Insert
*Update
*Delete
*Merge
3.DDL (data definiton language)
*Create
*Alter
*Rename
*Truncate
*Drop
4.TCL (data transaction language)
*Commit
*Savepoint
*Rollback
5.DCL (data control language)
*Grant
*revoke
Creating Tables
You must create your tables before you can enter data into them. Use the Create Table command.
Syntax: Create table tablename using filename
(fieldname fieldtype(length),
fieldname fieldtype(length),
fieldname fieldtype(length));
Explanation:
- A Select statement is a SQL statement that begins with the word "select."
- Select statements are used to retrieve data from SQL tables.
- An asterisk after the word "select" means retrieve all fields (columns).
- The name of the table from which you are retrieving data is specified in the From clause.
- Use a semicolon to signify the end of a SQL statement.
Create table TrnVendor using 'TVendor.dat'
(VendId char(10),
Name char(30),
Add1 char(30),
City char(30),
State char(3),
CurrBal float(8),
ExpAcct char(10));
Retrieving All Data
Select statements are used to retrieve data from SQL tables. The Select statement illustrated below retrieves all of the columns and rows from the named table.Syntax: Select * from tablename;
Inserting Rows
You can insert new rows into a table by using insert command in SQL
Syntax: Insert into tablename ( fieldname, fieldname, fieldname) values ( value, value, value);
(VendId char(10),
Name char(30),
Add1 char(30),
City char(30),
State char(3),
CurrBal float(8),
ExpAcct char(10));
Retrieving All Data
Select statements are used to retrieve data from SQL tables. The Select statement illustrated below retrieves all of the columns and rows from the named table.Syntax: Select * from tablename;
Explanation:
§ A Select statement is a SQL statement that begins with the word "select."
§ Select statements are used to retrieve data from SQL tables.
§ An asterisk after the word "select" means retrieve all fields (columns).
§ The name of the table from which you are retrieving data is specified in the From clause.
§ Use a semicolon to signify the end of a SQL statement.
Example:
Retrieve all of the data from the TrnVendor table.
Select * from TrnVendor;
Inserting Rows
You can insert new rows into a table by using insert command in SQL
Syntax: Insert into tablename ( fieldname, fieldname, fieldname) values ( value, value, value);
Explanation:
Ø When inserting data, use the Start Transaction command so that any errors can be rolled back.
Ø You must specify the values to be inserted.
Ø When performing an insert, enclose character values in single quotes.
Ø Do not enclose numeric values in single quotes.
Ø Use the Rollback Work command to undo changes.
Ø Use the Commit Work command to finalize changes.
Example: Insert the following vendor into the TrnVendor table
VendorId : TV055
Name : PartyGames
Address : POBox136
City : Chicago
State : IL
Current Balance: 2498.62
Name : PartyGames
Address : POBox136
City : Chicago
State : IL
Current Balance: 2498.62
Insert into TrnVendor (VendId, Name, Addr1, City, State, CurrBal )
values ( 'TV055', 'Party Games', 'PO Box 136', 'Chicago', 'IL', 2498.62);
values ( 'TV055', 'Party Games', 'PO Box 136', 'Chicago', 'IL', 2498.62);