Python课程-w73班
Louyj's Blog
Toggle navigation
Python课程-w73班
Home
班级课件
课堂代码
课后作业
学习资料
Archives
Tags
2022-12-11课堂代码
2022-12-11 13:48:20
13
0
0
python-w73
``` --创建表 create table create table 表名 (列名1 列类型,列名2 列类型, ..., 列名n 列类型); -- 分号;用户分隔多条sql语句, 多个sql语句同时执行, 分号必不可少. 如果只执行一条sql, 分号可有可无 create table student_01 (student_no text, name text, birthday text, sex text); --添加数据(插入数据) insert into 表名 (列名1,列名2,...,列名n) values (数据1,数据2,...,数据n); --sql中字符串必须只能用单引号, 不能用双引号 insert into student_01 (student_no, name, birthday, sex) values ('0001','张三','2000-10-11','男'); --当插入的字段是表里面所有字段时, 字段列表可以省略. 条件是数据的顺序必须和字段的顺序保持一致 insert into student_01 values ('0001','张三','2000-10-11','男'); insert into student_01 values ('张三','0001','2000-10-11','男'); -- 使用sql建一张成绩表 score_01 --查询数据 select 列名1,列名2,...,列名n from 表名; select student_no,name,birthday,sex from student_01; --当我们查一张表的所有字段时, 可以用*代替字段名 select * from student_01; --条件查询, 列表=列值 (比较运算符) (相等: =) <><=>=!= select * from student_01 where student_no='0001'; select * from student_01 where name='张三'; --sql同样支持逻辑运算符, and or select * from student_01 where student_no='0001' and name='张三'; select * from student_01 where student_no='0001' or name='李四' and sex='男'; -- select * from student_01 where student_no in ('0001','0002'); ```
Pre:
2022-12-18课件-python操作sqlite数据库
Next:
2022-12-11课件-SQLite基本语法
0
likes
13
Weibo
Wechat
Tencent Weibo
QQ Zone
RenRen
Submit
Sign in
to leave a comment.
No Leanote account?
Sign up now.
0
comments
More...
Table of content
No Leanote account? Sign up now.