Magazine
 
MySQL
 

rows that have been inserted into your tables.

SQL statements are divided into two major categories:

Data Definition Language (DDL)
Data Manipulation Language (DML)

Data Definition Language (DDL):
DDL statements are used to define and modify the database structure of your tables or schema. When you execute a DDL statement, it takes effect immediately.
Some commands of DDL are:

  • CREATE - to create table (objects) in
    the database
  • ALTER - alters the structure of the
    database
  • DROP - delete table from the database
  • TRUNCATE - remove all records from a
    table, including all spaces allocated for
    the records are removed
  • COMMENT - add comments to the data
    dictionary
  • RENAME - rename a table

1. The create table statement (query) to create a table is given below:

CREATE TABLE <table name> (
<attribute name 1> <data type 1>,
...
<attribute name n> <data type n>);

Example:

CREATE TABLE STUDENT ( StudID NUMBER, Name VARCHAR);

The data types that you will use most frequently are character strings, which might be called VARCHAR or CHAR for variable or fixed length strings; numeric types such as NUMBER or INTEGER, which will usually
specify a precision; and DATE or related types. Data types are differ according to the databases software whatever you are using to your system.

 

2. The alter table statement to make modifications to the table structure such as Key constraints, Column size, etc.

ALTER TABLE <table name> ADD CONSTRAINT <constraint name> PRIMARY KEY (<attribute list>);

Example:

ALTER TABLE STUDENT
ADD CONSTRAINT NOT NULL PRIMARY KEY
(StudID);

3. The delete table statement (query) to delete a table is given below:

DROP TABLE <table name>;

Example:

DROP TABLE STUDENT;

Data Manipulation Language

Data Manipulation Language (DML) statements are used for managing data within tables. Some commands of DML are:

  • SELECT - retrieve data from the a database
  • INSERT - insert data into a table
  • UPDATE - updates existing data within a table
  • DELETE - deletes all records from a table, the space for the records remain
  • MERGE - UPSERT operation (insert or update)
  • CALL - call a PL/SQL or Java subprogram
  • LOCK TABLE - control concurrency
Dec  2007 | Java Jazz Up | 20
 
previous
index
next
 
View All Topics
All Pages of this Issue
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,

30
, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 , 54, 55, 56, 57,

58
, 59, 60, 61, 62, 63 , 64, 65 , 66 , 67 , 68 , 69 , 70 , 71 , 72 , 73 , 74 , 75 , 76 , 77 , 78 , 79 , 80 , 81 , 82 ,

Download PDF