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

相关推荐
Arbori_262158 分钟前
oracle update 原理
数据库·oracle
hxung1 小时前
Spring @Transactional 注解
数据库·spring·oracle
追逐时光者2 小时前
精选 4 款免费且实用的数据库管理工具,程序员必备!
数据库
生命有所坚持而生存可以随遇而安2 小时前
MySQL5.7数据库部署和安装
数据库·adb
未来的资深Java架构师2 小时前
MySQL报Lock wait timeout exceeded; try restarting transaction
数据库·mysql
kikyo哎哟喂2 小时前
MongoDB常见面试题总结(上)
数据库·mongodb
java奋斗者2 小时前
新闻推荐系统(springboot+vue+mysql)含万字文档+运行说明文档
spring boot·后端·mysql
孙同学_2 小时前
【MySQL】002.MySQL数据库基础
数据库·mysql
码农101号2 小时前
数据库视图讲解(view)
数据库·sql
喝醉酒的小白3 小时前
SQL Server:数据库镜像端点检查
数据库