CREATE database table and perform SQL Insert-Update-Delete Commands

by top54u.com 06 Nov, 2007
  

CREATE TABLE USING SQL SYNTAX

CREATE TABLE table_name
(
 Column_name1 datatype([size]),
 Column_name2 datatype([size]),
)

Example:
CREATE TABLE
tbl_customer
(
 customer_id int,
 fname  varchar(50),
 lname  varchar(50),
 phone  varchar(16),
 address varchar(100),
 city  varchar(50)
)

  
SQL INSERT Command
SQL insert statement is used to add new record into the table.

SQL INSERT SYNTAX:

INSERT INTO table_name ([column names separated with commas])
VALUES (data values)

Example:
Insert into tbl_customer(customer_id, fname, lname, phone, address, city) Values (‘172-32-1176’, ’White’, ‘Johnson’, ‘408 496-7223’, ’10932 Bigge Rd.’, ‘Menlo Park’)

  

SQL UPDATE Command
SQL update command is used to modify the previously added data in the database.

SQL UPDATE SYNTAX:

UPDATE table_name SET column_name = {value to assign}
WHERE {Search condition}

Example:
UPDATE tbl_customer SET city = ‘Park Plaza’ WHERE customer_id = ‘172-32-1176’


SQL DELETE Command
SQL delete command is used to delete the rows from the table.

SQL DELETE SYNTAX:

DELETE FROM table_name WHERE {search condition}

Example:
To delete all rows from the table:
DELETE FROM tbl_customer

To delete specific rows:
DELETE FROM tbl_customer WHERE customer_id = ‘172-32-1176’

 

Following are the Base Data types for SQL Server 2000 and above that can be used to specify the column data type appropriate for the data that is to be inserted into the particular column are:

binary

bigint

bit

char

datetime

decimal

float

image

int

money

nchar

ntext

nvarchar

numeric

real

smalldatetime

smallint

smallmoney

sql_variant

sysname

text

timestamp

tinyint

varbinary

varchar

uniqueidentifier

 

 

 

To learn SQL SELECT statement click here...

Spotlight.....

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , , , ,

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

10/11/2008 3:41:34 AM




related videos.....
recent posts.....
top54u ezines.....