SQL Tutorials

I would like to explain Tutorial of SQL.

How to Create a Table :

Table Creation Syntax :

Create table TableName
(

ColumnName  datatype(size),
ColumnName  datatype(size),
ColumnName  datatype(size),
.
.
.

);


Table Creation Example :

Create table Customer
(
 CustomerID varchar(500),
 CustomerName varchar(500),
 CustomerCity varchar(500),
 CustomerAddress varchar(500),
);

How to Insert data into table : 

 

Insert into tablename(column1,column2,....) values(column1_value,column2_value,...);
you can insert data into the table as,
1. for inserting all column values into the table

Syntax:

       Insert into Customer values(column1_value,column2_value,...);

Example :

       Insert into Customer values('SDB20150001','Satish','Hyderabad','Ameerpet');
 

2. for inserting only required columns into the table
       
Syntax:
       Insert into Customer(column1,column3) values(column1_value,column3_value);

Example :

       Insert into Customer(CustomerID,CustomerCity) values('SDB20150001','Hyderabad');

 

 

How to see Table Data 

 

Select * from TableName;

Example :  Select * from Customer;



 

How to Update a Table : 

 

Update tablename  
SET column1=value1,column2=value2,...
WHERE Column =value;

Example :

Update Customer 
Set CustomerName='Satish'  
Where CustomerID='SDB20150001';




Where I am updated the column CustomerName value Satish as Satish, Hera I updated satish with satish only.


How to Delete a Entire Data from Table : 

 

Delete * from Customer;


No comments:

Post a Comment