2_表中内容的增删改查


注意:

删除库和表用drop DB_abc; drop T_score;

删除表中行的内容用delete 列的内容drop column


-----------------------------

创建一张表:create table score(id int,name char(10),age int);

建完表后,可以查看表结构:desc score;


对表中的内容进行增、删、改、查操作:

1.增

insert into score

(id,name,age)

values

(3,"sanba",35);


insert into score

(id,name,age)

values

(1,"zhangsan",32),

(4,"zhouqi",22),

(5,"zhaoliu",33);


上面的是增加行,现在来增加列:alter table score add sex int;


2.删

delete from score

where id=1;


上面是删除行,现在来删除列:alter table score drop sex;


3.改

update score

set

id = 1

where

name="lisi";


4.查

select * from score;//查询表中所有的内容


select id,age from score;//查询表中id,age项


select id,age from score where id>2;//查询表中id,age项,并且id>2



你可能感兴趣的:(update,insert,create,values)