寒假作业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

相关推荐

  1. 寒假作业7

    2024-02-09 12:52:01       28 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-02-09 12:52:01       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-02-09 12:52:01       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-02-09 12:52:01       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-02-09 12:52:01       18 阅读

热门阅读

  1. Ubuntu 1804 And Above Coredump Settings

    2024-02-09 12:52:01       30 阅读
  2. 【Redis笔记】分布式锁及4种常见实现方法

    2024-02-09 12:52:01       30 阅读
  3. Rust入门2——随机数

    2024-02-09 12:52:01       31 阅读
  4. json模块(高维数据的存储与读取)

    2024-02-09 12:52:01       23 阅读
  5. Rust中的 Cell 和 RefCell

    2024-02-09 12:52:01       28 阅读
  6. 509. 斐波那契数

    2024-02-09 12:52:01       32 阅读
  7. 【Golang】定时任务Cron指南-毫秒级任务支持

    2024-02-09 12:52:01       31 阅读
  8. Flutter typedef 函数类型

    2024-02-09 12:52:01       30 阅读
  9. 速盾:dns解析和cdn加速的区别与联系

    2024-02-09 12:52:01       34 阅读