Monday, 5 September 2016

Create , Insert , and Select Query in SQL

Create , Insert , and Select Query in SQL

Create :- The CREATE TABLE statement is used to create a table in a database.

SYNTAX :- 
                CREATE TABLE table_name(
                                      column1 datatype,
                                      column2 datatype,
                                      column3 datatype,
                                      .....
                                      columnN datatype,
                                      PRIMARY KEY( one or more columns )
                                     );
EXAMPLE :-

CREATE TABLE Emp1(
ID int not null,
Name varchar(50),
Company varchar(50),
Salary varchar(50),
);

CREATE TABLE User1(
ID int not null,
Name varchar(50),
City varchar(50),
);




 INSERT :- The SQL INSERT INTO Statement is used to add new rows of data to a table in the database.

SYNTAX :- INSERT INTO TABLE_NAME
                                       (column1, column2, column3,...columnN)
                             VALUES
                                     (value1, value2, value3,...valueN);
EXAMPLE :-
      
INSERT INTO Emp1 VALUES (1,'RAM','TCS','30000'),
(2,'SHYAM','TCS','78500'),
(3,'MOHAN','HP','58000'),
(4,'GEETA','HP','85000'),
(5,'SITA','WIPRO','44000'),
(6,'LAKSHMAN','WIPRO','5500'),
(7,'RAHIM','DELL','43000'),
(8,'AKASH','DELL','34000'),
(9,'RANI','HCL','54000'),
(10,'SOHAN','HCL','45000');

INSERT INTO User1 VALUES (1,'RAM','Nagpur'),
(2,'SHYAM','Pune'),
(3,'MOHAN','Dehradun'),
(4,'GEETA','Himachal'),
(5,'SITA','Nainital'),
(6,'LAKSHMAN','Punjab'),
(7,'RAHIM','Hariyana'),
(8,'AKASH','Noida'),
(9,'RANI','Delhi'),

(10,'SOHAN','Mumbai');


SELECT :- SQL SELECT statement is used to fetch the data from a database table which returns data in the form of result table. These result tables are called result-sets.

SYNTAX :- SELECT column1, column2, columnN FROM table_name;

EXAMPLE:-

            SELECT * FROM Emp1;


            SELECT * FROM User1;



No comments:

Post a Comment

Factorial of a Number

Recently Viewed