SQL数据库基本操作语言

select * from studinfo

/第一种/
insert into 表名 values(值1,值2,值3,值4)

insert into stuinfo values(‘name’,‘sex’,age,‘home’) /字符、字串加单引号/

/第二种:有选择的筛选某一列 非空列必须加,自动增长列可以不加/
insert into stuinfo(列a,列b……) values(值aa,值bb……)

insert into stuinfo(stuName,stuGender,stuAddress) values(‘name’,‘sex’,‘home’)

/update/
update 表名 set 列1 = 值1,列1 = 值1,列1 = 值1……
where 筛选条件

update stuinfo set stuGender=‘sexvalue’
where stuname = ‘namevalue’

/delete/
delete from 表名

/*search 通配符 _(下划线)代表一个任意的字符 %代表任意长度的字符串 */
like ‘陈%’
like ‘%陈%’

/special search/
update stuinfo set stuGender = ‘女’,stuAge = 22
where stuName like ‘陈%’
/* where stuName = ‘陈%’*/

update stuinfo set stuGender = ‘女’ where stuage >= 20 and stuage <= 40

/search/
select 列名 from 表名
where 条件筛选
order by 排序
limit 限制数据行
聚合函数 sum() avg() count() max() min()
连接查询

/as语法呈现/
select stuid,stuname,stuaddress from stuinfo
select stuid as 学号,stuname as 姓名

select * from stuinfo where stuName like ‘刘%’ or ‘王%’

发布了95 篇原创文章 · 获赞 19 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_43345204/article/details/100132262
今日推荐