Print this Page

SQL

SQL HISTORY:-

Sql is a special purpose programming language design for managing data held in a RDBMS. SQL was one of the first commercial language for E.F. codes relational model as described in paper “A relational modal data for large share data banks” SQL become standard of the ANS II. in 1986 and of the international organization of 1987.since then standard has been enhanced several times with added features. SQL was initatty developed by IBM donald chamberlin  and Raymond F. Boyce  in the early 17. this version initially called SEQL (stranded English quarry language) was designed to manipulate and retrieve  data in IBM’S RDBMS known as system R. the name SEQL was changed to SQL latter.                                                                                                                                                                                                    After testing sql at the IBM they made commercial produces  include system 38,sql-DB and they are commercial available in 1979 ,1981,and 1983  respectively.

the different version of SQL was SQL 86, SQL 89, SQL 92, SQL 99, sql  server 2003, sql server 2008, and  sql server 2011. originally algebra and relational calculus was add to sql for better performance sql consist of different languages like data definition language ,data manipulation language for inserting quarry, updation and deletion as wellas schema creation modification data acess control .sql is describe as declarative language as it is include procedural elements (procuder function , cursor and triggers).

There are two types of sql command:-

  • DDL – Data Definition Language
  • DML – Data Manipulation Language 
  •   DDL(data definition language )DDL commands help us to design our schema design new table . After exiting table and deleting the table in short we can make table change the existing table column and deleting the structure if exiting table.the most important of DDL commands are create,alter ,drop ,truncate for collect .
  • IMPORTANT DDL COMMANDS ARE  CREATE, ALTER, DROP,TRUNCATE

CREATE TABLE COMMANDS:-

this commands is use to create table having a name ,it is data type of each column and can implement constant . A table is uniquely defined and identified by it is name and consist of rows that  contains the stores information ,A table can have one or more columns.it can have up to 254 column which may have different or same data type

syntax:-HOW TO CREATE A TABLE

create table <table name>

(<column name 1><data type><size>

<column name 2><data type><size>

<column name 3><data type><size>);

As

create table student

(roll no number(5) unique,

name character (20)

address varchar2(30)

phone no(10) not null);

data type :-there are no of data types available in sql .

1 char strings

(a) char(size):-it is fixed size fiekd of character .if we do not specify any size then it is taken as 1.it can hold up to 2000 character and thus 2000 bytes.

(b) varchar (size):-it store the variable size of data. it is more suitable then char because it can be store in a less space.it can hold up to 2000 character

(c) varchar2(size):-it store the variable sizeof data. it is more suitable then char because it can be store in a less space .it can hold up to 4000 char.

(d) long :-it store the variable size character field. it can store up to 2Gb of data.

  • ALTER COMMAND:-the definition of existing relation can be altered or change by using this command.
  • syntax:-alter table <exiting table name >add<column name><data type><size><constant>,
  • EXAMPLE:-alter table student add(email varchar(30));
  • it will add a column email to the exiting table student.
    • HOW TO MODIFYING THE COLUMN OF AN EXITING TABLE
    • SYNTAX :-alter table (<exiting table name >modify<exiting table name><data type><increased size>);

DROP COMMAND:-this commands is use to remove or delete the table with all it is data .

syntax:-drop table<table name>;

ex:-sql>drop table student;

TRUNCATE COMMAND:-

this command is use to remove all the data from the table leaving the structure intact.the table is nit deleted by this command only the data or rows will we removed.

syntax:-truncate table <table name>;ex:-truncate table student;

CONNECT COMMAND:-the connect command use to the data base .it help us to use the data base items like table view e.t.c

syntax:- connect<user name>/<password> or connect<username >then password<password>

if the user name or password is create then it will show “connect” as an out put.

for example:-sql>connect system /system123( then it will show connected).

system:-user can be made if we have the privilege to make user like this.

syntax:-create user <username>

identified by<password>;

example:-create user system identified by system123 user created.

to inter into that user simply type

sql>connect system /system123

(2)DDL:-(data manipulation language):-to manipulate data there are some commands available like insert rows,update any exiting data items as well as to delete rows with specified condition.

  • INSERT COMMAND:-this command is use to insert rows or row to particular table.
  • syntax:-insert into <table name>(<column name1>,<column name2>,<column name3>)vlues(<data items1>,<datai tems2>,<data items3>);  or

insert into metric(roll,name,result)value (11,ram,pass);

  • UPDATE COMMAND:- this command is use to modifying or change row and rows (data items)
  • syntax:- update<table name>set<column name1>=<value>where<condition>
  • update metric set name=ram where roll=12
  • example:- update metric set name=’Ram’ result=’pass’ where roll=10 and name =’ram’
  • DELETE COMMAND:- this helps to delete rows or row from table.
  • syntax:-delete from <table name>where<condition>;
  • example:-delete from metric where roll=10;
  • delete from metric where roll=5 and name =’ram’;

sql:- delete from metric;    ( it will delete all the rows from the table.)

(3)DATA QUERY LANGUAGE:-

This language has only one command that is select command. select command is use to query object like table,views and to get the desire data from the exiting object. the select command is corresponding projection operation of the relation algebra. it is use to list the attributes desire is the result of the query.

syntax :-select<column name1>,<column name2>,<column name3>,form<exiting table name>where <condition>;

  • example:- select name,result  from student where  roll>2; or   select name,result,=’fail’ and roll>2;
  • SELECT *FROM STUDENT; (THIS COMMAND IS USE TO SHOW ALL THE COLUMN OF THE TABLE)

Permanent link to this article: http://www.techxpress.in/sql/

Advance

SQL Advance Commands:

View page »

Leave a Reply

Bookmark this page