首页 技术 正文
技术 2022年11月7日
0 收藏 868 点赞 879 浏览 1176 个字

1.注释语法:–,#
2.后缀是.sql的文件是数据库查询文件
3.保存查询
4.在数据库里面 列有个名字叫字段   行有个名字叫记录

CRUD操作:
create 创建(添加)
read 读取
update 修改
delete 删除

1、添加数据
insert into Info values(‘p009′,’张三’,1,’n001′,’2016-8-30 12:9:8′) ;
给特定的列添加数据
insert into Info (code,name) values(‘p010′,’李四’);
自增长列的处理
insert into family values(”,’p001′,’数据’,’T001′,’数据’,1);

insert into 表名 values(值)

2、删除数据
删除所有数据
delete from family
删除特定的数据
delete from Info where code=’p001′

delete from 表名 where 条件

3、修改数据
修改所有数据
update Info set name=’徐业鹏’
修改特定数据
update Info set name=’吕永乐’ where code=’p002′
修改多列
update Info set name=’吕永乐’,sex=1 where code=’p003′

update 表名 set 要修改的内容 where 条件  tno =

4、读取数据
(1)简单读取,查询所有列(*)  所有行(没有加条件)
select * from Info
(2)读取特定列
select code,name from Info
(3)条件查询
select * from Info where code=’p003′
(4)多条件查询
select * from Info where code=’p003′ or nation=’n002′ #或的关系
select * from Info where sex=0 and nation=’n002′ #与的关系
(5)关键字查询(模糊查询)
查所有包含奥迪的汽车
select * from car where name like ‘%奥迪%’; #百分号%代表任意多个字符
查以’皇冠’开头的所有汽车
select * from car where name like ‘皇冠%’;
查询汽车名称中第二个字符是’马’的
select * from car where name like ‘_马%’; #下划线_代表任意一个字符
(6)排序查询
select * from car order by powers  #默认升序排列
select * from car order by powers  #升序asc 降序 desc
先按brand升序排,再按照price降序排
select * from car order by brand,price desc
(7)范围查询
select * from car where price9()>40 and price<60
select * from car where price between 40 and 60

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,497
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,909
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,744
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,497
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,135
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,298