Home > DeveloperSection > Interviews > Basic operation CREATE , INSERT, UPDATE and DELETE in SQL.

Posted on    September-27-2016 7:14 AM

 MSSQL Server SQL Server 
Ratings:
 1 Answer(s)
  111  View(s)
Rate this:

Abhishek Srivasatava
Abhishek Srivasatava

Total Post:70

Points:350
Posted on    September-27-2016 7:14 AM

How to create table?

 

Table can be form by 2 ways:

 

Programming method and manual method.

 

Programming Method

 

  Example : CREATE TABLE EE_EMPL_CAT
( PRSN_INTN_ID  int NOT NULL PRIMARY KEY ,
EMPL_STAT_CD char(20)  NOT NULL ,
NAME  char(10,
REFERENCE_ID int,
);

 

2nd method is the manual method. You need to follow following step.

 

Under database à under Table section right click on table point to new table.

Name the Column Name like ee_intn_id etc, datatype, check or unchecked the ‘Allow Null’ column. 

Save the table.

For putting constraint on your table read this Cluster and non-cluster index in SQL and Different types of Constraints in SQL.

 

How to insert data into the table?

 

Below is the syntax to insert.

INSERT INTO EE_EMPL_CAT1 (PRSN_INTN_ID, [EMPL_STAT_CD],[NAME],REFERENCE_ID)
    VALUES (1199667, 'ACTIVE', 'DAVID',159978)

 

How to Update data into the table?

 

Below is the syntax to Update.

 
UPDATE EE_EMPL_CAT1
    SET NAME = 'SMITH'
    WHERE PRSN_INTN_ID = 1199668


How to delete the data from the table?


Below is the syntax to Delete:

 DELETE FROM EE_EMPL_CAT1
    WHERE NAME = 'DAVID'
    

Modified On Sep-27-2016 07:15:38 AM

Don't want to miss updates? Please click the below button!

Follow MindStick