SQL语句

发表于2008年08月02日 12:46 阅读(8) 评论(0)

 

1.select
SELECT * FROM chinese ;
SELECT name as 姓名 FROM chinese ;
SELECT * FROM chinese c where age between 18 and 30;

SELECT * FROM test1 t where realist = false and interesting is not null;

SELECT * FROM test1 t where realist = false or interesting is not null;
SELECT * FROM chinese c where name like '%黄%' order by name asc;   //升序
SELECT * FROM chinese c where name like '%黄%' order by name desc;  //%任意字符串
SELECT * FROM chinese c where phone like '55_' order by name desc;  //_任一字符
SELECT count(*) as '记录数' FROM chinese c;     //计下有几条记录
SELECT count(age) as 'ageNO' FROM chinese c;    //计下记录中age不为空的数目
SELECT sum(age) as '全部人总年龄' FROM chinese c;  //求age字段的值总和
SELECT avg(age) as '平均年龄' FROM chinese c;     //总和 / !非空值!记录数
SELECT max(age) as '最大年龄' FROM chinese c;
SELECT min(age) as '最小年龄' FROM chinese c;
2.insert
insert into test2 (name,phone) values ('zhaozhao','13222445566');
3.update
update test3 set phone = '13912345678' where name = 'zhaozhao1'
4.delete
delete from test3 where phone = '13912345678'         //删除记录集 ,系"集"
delete from test3      //删除表中所有记录

5.drop
drop table test3      //删除表
6.create

create table test3 ( UserId char(5),name char(20),phone char(20),Userright boolean,primary key(UserId) )

      //primary key    定义主键

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章