SQL语句

本文详细介绍SQL的基本操作,包括数据查询、插入、更新、删除等核心命令,并提供了具体示例,帮助读者快速掌握SQL的使用方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

发表于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    定义主键

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值