create table <表名>
(
<列名> <数据类型及长度> [not null],
<列名> <数据类型及长度>,
...
<列名> <数据类型及长度>
)

primary key 主键
not null 非空
foreign key(Nation) references Nation(Code) 外键
auto_increment 自增长

注意:所有符号必须是英文状态下的
每个表创建完之后加分号
表里面的最后一列写完之后不要加逗号

删除表:
drop table PinPai

增,删,改,查 CRUD

添加:
insert into <表名>[(列1,列2....)] values(<'值1'>[,'值2'])
注意:
1.列与值要匹配(数量,类型,次序)
2.列可以省掉,但值必须与表中的总列数和列的次序完全对应。
3.自增长列,不能省掉自增列,给自增列赋个''

delete from car where code='c001'
delete from car where brand='b001' or brand='b004'
delete from car where brand='b001' || brand='b004'
delete from car where brand='b007' && price>50
delete from car where brand='b007' and price>50

<> !=

更新
update <表名> set <列=值>[,列=值...] where .....
update info set sex='1' where code='p003'
update info set sex='0',nation='n004',birthday='1999-9-9' where code='p001'
update car set price=price * 0.9 where price > 30
update car set price =price * 0.95 where (brand='b006' || brand='b005')&&price>30

查询
select * from 表名
select 列名1,列名2... from 表名 --投影
select * from 表名 where 条件 --筛选

1.等值与不等值
select * from car where code='c001';
select * from car where code != 'c001';
select * from car where price > 30;
--下面的都是范围
select * from car where price >=30 && price <=50;
select * from car where price between 30 and 50
select * from car where brand='b002' || brand='b004' || brand='b006'
select * from car where brand in ('b002','b004','b006')

2.模糊查
select * from car where name like '宝马%' %--任意多个任意字符
select * from car where name like '%5%'
select * from car where name like '%型'
select * from car where name like '__5%' _ -- 一个任意字符

3.排序
select * from 表名 where .... order by 列名 [ASC/DESC],列名[asc/desc]....

select * from car order by price desc
select * from car order by brand desc,price asc

最新文章

  1. On One Side Kolmogorov Type Inequalities
  2. java:快速文件分割及合并
  3. C#之读取web上的xml
  4. BZOJ-3282 Tree Link-Cut-Tree(似乎树链剖分亦可)
  5. openssl rsa 私钥 PKCS8私钥 公钥
  6. 使用ndk standalone工具链来编译某个平台下的库
  7. xp 下卸载 硬盘安装的 ubuntu (本人的悲伤史)
  8. 由浅入深吃透MVC框架,驯服烂代码
  9. HTML5API___geolocation
  10. Python数据分析Pandas库之熊猫(10分钟二)
  11. springcloud config 提取公共参数
  12. 1.RN环境搭建,创建项目,使用夜神模拟调试
  13. 服务端线程模型-NIO服务模型
  14. Codeforces 660C - Hard Process - [二分+DP]
  15. mongodb 初学 意外 连接服务器异常(Connection refused)
  16. PLSQL Developer是什么?
  17. Kubernetes之解决从k8s.gcr.io拉取镜像失败问题
  18. Dubbo创建提供者&amp;消费者工程
  19. Redis常用类型数据操作
  20. lightoj1234调和级数+欧拉常数

热门文章

  1. Swift开发学习-03 Swift技巧
  2. mvc中EditorFor TextBoxFor什么区别
  3. tomcat8编码
  4. unity3d下载Obb分包文件
  5. asp.net环境变量
  6. [转载]sed 简明教程
  7. linux 的终端字体色和背景色的修改方法(一)
  8. Windows下Git Bash中文乱码
  9. Ubuntu技巧之 is not in the sudoers file解决方法
  10. ubuntu系统 用户进入后命令行只有一个“$” 美元符号