寒假作业7

sql语句

创建表格

create table 表名 (字段名  数据类型,字段名  数据类型)

create table if not exists 表名 (字段名 数据类型, 字段名  数据类型)

删除表格

drop table 表名;

插入记录

全字段插入

insert into 表名 values (数据 1 ,数据2 ,数据 3)

部分字段插入

insert into 表名(字段名1 ,字段名2)values(数据1,数据2)

查看记录

.header on 打开表头

.mode column 对齐

查看所有记录

select *from 表名

查看某几行

select  *  from 表名 where 限制条件

逻辑与 and   逻辑或 or

查看某几列

select 字段1,字段2  from 表名

select 字段1,字段2  from 表名 限制条件

修改记录

updata 表名 set 字段=数值 where 限制条件

删除记录

delete from 表名 where 限制条件

主键

primary key 

拷贝

从a中拷贝所有数据到b中

create table b as select * from a

从a中拷贝指定字段到b中

create table b as select 字段,字段,字段from a

增加列 

alter table 表名 add colum 字段名 数据类型

修改表名

alter table 旧表名 rename to 新表名

修改字段名(列名)

将表名重新命名

alter table stuinfo rename to stu;

新建修改名字后的表(新建一个a)

create table stuinfo (name char ,age1 int ….)

从旧表b中取出数据,插入到新表a中

insert into stuinfo select  *  from stu

删除列

创建一个新表b,并复制旧表a需要保留的字段信息

create table stu as select name,age1,sex from stuinfo

删除旧表a

drop table stuinfo 

修改新表b的名字a

alter table stu rename to stuinfo 

接口

sqlite3_open

sqlite3_close

sqlite3_errmsg

sqlite3_errcode

sqlite3_exec

sqlite3_get_table

sqlite3_free_table

本文来自网络,不代表协通编程立场,如若转载,请注明出处:https://net2asp.com/45f216b55b.html