Monday, February 7, 2011

About SQL and different commands

Introduction to SQL
  • SQL is referred as Structured query language, is database computer language required for managing the data relational data base management system.It acts as Interface for database only,universal interface.
  • SQL is Non-Procedural language and it is 4th generation language.
  • Procedural means execution from top to bottom and it is 3rd generation language.
 Different types of commands:-
  1. Data definition language(DDL)
  2. Data manipulation language(DML)
  3. Transaction control language (TCL)
  4. Data control language(DCL)
  5. System control language(SCL)
  6. Session control language(SCL)
  7. Data Query/Retrieval language
SQL commands ready to work with any platform.It is independent of O/S.It is permission oriented language or it requires privileges.It is exclusively used for DB because it a DB language.
DDL consists of :
  1. Create
  2. Alter
  3. Drop
DML consists of :
  1. Select
  2. Update
  3. Delete
  4. Insert
TCL consists of :
  1. Savepoint
  2. Commit
  3. Rollback
DCL consists of:
  1. Grant 
  2. Revoke
CREATE:
Create command is used to create the DB objects like table,view, synonym, sequence, user, index, cluster, tablespace, segment, database, DBlink, proceduire, Function, Package, Trigger, Role, Directory type...
Syntax
CREATE TABLE TABLENAME
( datatype(width), datatype(width));Ex:  create table student(RollNum number(3), Name varchar2(10)); 
 
Various datatypes  
 
  • Char(size): To store fixed length char strings.Max upto 2000 bytes.By default 1 Byte.  
  • Varchar(size):To store variable length.Max 4000 Bytes. Difference between varchar and char is that when we use char and assign the size all the placed are reserved for that column and where as varchar releases the memory when they are not used. 
  • LONG: Data upto 2 GB can be stored. 
  • RAW:To store binary data like signature,Thumb,impressions,photographs. 
  • Long Raw: To store binary data upto 2GB size No default. 
  • LOB: large objects  
  • CLOB: char large objects  
  • BLOB:Binary large objects.
  • Bfile:Binary file 
  • Number(P,S):where P is primary, S is secondary(where P is left size of precision,S is right side precision) Ex:Salary number(6,2).   Date: DD-MM-YY
will be contd....

No comments: