third day

对表的一些基本操作

Creating a Table

syntax
CREATE TABLE Tablename
 (column_name type,  column_name, type, .....)
for example
CREATE TABLE  Employee (names     VARCHAR(20),
                         
                        address    VARCHAR(20),
                         
                        employee_number  INT,
                        
                        salary           SMALLMONEY)

 2

Inserting Values into a Table

the two way to insert values into a table

one way  to insert values into one row of  a table is   to use the INSERT INTO command

 with the VALUES option.

syntax :

INSERT INTO TableName
VALUES ('character_attribute_value', numeric_attribute_value, ...)


the other way  we can  insert many rows into a table at one time.

syntax:

INSERT INTO Names(fullname)
  SELECT  names
  FROM    Employee


3

The UPDATE Command

to set /change data values in a table ,we use the update command.

syntac:

UPDATE TableName

SET fieldname

for example

UPDATE Emp2

SET sal = 0    --把表中雇员的薪水都改为0

或者写成

UPDATE Emp2

SET sal = 1000

WHERE aga > 40   --讲年龄大于40雇员工资改为 1000

 

4 
The ALTER TABLE Command
if you  want to add ,change,delete column in a table, wo will use the ALTER TABLE command.
for example
ALTER TABLE 
 Tablename
ADD column-name type
 
5 
 
the DELETE Command
 
we use the DELETE command to delete the row of a table what we want to .
Syntar:
DELETE FROM Table
WHERE(condition)
for example
DELETE FROM student
WHERE(age>16)--删除学生表中 年龄大于16岁学生的信息
 
if you want to delete entire table
please write 
DROP TABLE Tablename
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值