当前位置:首页 > 汽车 >

sqlite怎么删除指定的记录(sqlite删除所有数据库)

来源:原点资讯(www.yd166.com)时间:2023-04-22 14:33:36作者:YD166手机阅读>>

3.1退出命令 .exit .quit

3.2查看表 .table

sqlite怎么删除指定的记录,sqlite删除所有数据库(5)

查看了建立好的fruit1

3.3查看表的结构

sqlite怎么删除指定的记录,sqlite删除所有数据库(6)

下面是sql语句:

3.4创建表A:create table A(id integer , name text , age integer , score float);

3.5插入记录:insert into fruit1 values (1 , 'sa' , 20 , 13);

insert into fruit1 (id , name , score) values(1 , 'sa' ,20 ,13);

3.6删除一条记录:delete from fruit1 where name = 'sa' and score = 13;

3.7更新一条记录:update fruit1 set age = 20 where id = 1;

update fruit1 set age = 20 ,score = 13 where id = 1;

3.8增加一列:alter table fruit1 add column level char;

3.9删除一列:create table fruit2 as select id , name from fruit1;

drop table fruit1;

alter table fruit2 rename to fruit1;

3.10查看数据库记录:

select * from fruit1 where score >=0 and score <=50;

select * from fruit1;

select * from fruit1 where id = 1;

select * from fruit1 where id = 1 and name = 'sa'; //and or

select name , score from fruit1; //查询指定字段

3.11删除一张表:drop table fruit1;

四、sqlite3 数据库的API函数

4.1打开数据库

int sqlite3_open( const char *filename; //数据库的名字 sqlite3 **ppDb; //函数的回传的句柄二级指针 );

返回值:成功为0 SQLITE_OK ,出错为错误码(const char sqlite3_errmsg(sqlite3 *db))里面的参数为句柄一级指针。

4.2关闭数据库

int sqlite3_close(sqlite3 *db); //参数为回传句柄一级指针

sqlite怎么删除指定的记录,sqlite删除所有数据库(7)

返回值:成功为0 SQLITE_OK ,出错为错误码(const char sqlite3_errmsg(sqlite3 *db))里面的参数为句柄一级指针。

4.3执行sql语句

int sqlite3_exec( sqlite3 *db, //句柄的一级指针 const char *sql ,//sql语句的首地址 int (*callback)(void * arg ,int f_num,char ** f_value , char **f_name), //callback 参数1:sqlite3_exec传递来的参数,参数2:列数,参数3:列的值的地址,参数4:列的名称的地址 void *arg,//为回调函数传递参数 char **errmsg //错误消息 );

只有在执行查询语句时、才会传参

返回值:成功时返回SQLITE_OK

4.4查询函数

int sqlite3_get_table( sqlite *db, const char *sql, char* **result ,int *nrow ,int *ncolumn ,char** errmsg );

db:数据库的句柄

sql:sql语句

**result:二维数组 存放查询结果

nrow:表的行数

ncolumn:表的列数

errmsg:存放错误信息

,
上一页12末页

栏目热文

sqlite3参数设置(sqlite3操作实例)

sqlite3参数设置(sqlite3操作实例)

一、简介SQLITE3非常小,轻量级,就几百K大小;不需要用户名,密码,直接就可以对数据库进行操作。二、安装sqlite...

2023-04-22 14:09:17查看全文 >>

sqlite优缺点(sqlite 利弊)

sqlite优缺点(sqlite 利弊)

英文原文: https://blog.nelhage.com/post/reflections-on-performan...

2023-04-22 14:28:25查看全文 >>

sqlite3查询(sqlite3查询表信息)

sqlite3查询(sqlite3查询表信息)

今天学习使用Sqlite3创建数据库、表、运行查询,并记录学习过程欢迎大家一起交流分享。首先新建一个python文件命名...

2023-04-22 14:33:18查看全文 >>

sqlite3 菜鸟教程(如何注册sqlite3)

sqlite3 菜鸟教程(如何注册sqlite3)

白天看完阅兵式,咱们继续学习SQL,学好本领,报效祖国!前两天我们学会了创建数据库和创建表(Table),今天我们学习往...

2023-04-22 13:59:21查看全文 >>

sqlite3基本操作

sqlite3基本操作

前言数据在实际工作中应用非常广泛,数据库的产品也比较多,oracle、DB2、SQL2000、mySQL;基于嵌入式li...

2023-04-22 14:32:18查看全文 >>

sqlite3数据库高级使用

sqlite3数据库高级使用

SQLite在《嵌入式数据库sqlite3命令操作基础篇-增删改查,小白一文入门》一文中讲解了如何实现sqlite3的基...

2023-04-22 14:36:29查看全文 >>

sqlite3功能(sqlite3官网中文)

sqlite3功能(sqlite3官网中文)

关注开源中国OSC头条号,获取最新技术资讯SQLite3 详细介绍sqlite3pp该库对SQLite3 API使用...

2023-04-22 14:30:00查看全文 >>

sqlite3数据库优缺点(sqlite适合多少数据量)

sqlite3数据库优缺点(sqlite适合多少数据量)

来源:机器之心本文约4700字,建议阅读8分钟。本文介绍了十三个适合中级 Python 开发人员练手的项目。[ 导 读 ...

2023-04-22 14:25:55查看全文 >>

sqlite3.5教程(sqlite3 最新版)

sqlite3.5教程(sqlite3 最新版)

SQLite是一种轻量级的嵌入式关系型数据库管理系统,它可以在多种操作系统上运行,并且无需独立的数据库服务器。以下是一个...

2023-04-22 14:40:21查看全文 >>

煤气灶回火维修视频(家用煤气灶回火怎么修理)

煤气灶回火维修视频(家用煤气灶回火怎么修理)

燃气灶“回火”指的是燃气高浓度聚集在灶具内,点火时出现爆燃现象,生活中一般发生于连续点火时。燃气灶“回火”会造成什么危...

2023-04-22 14:11:50查看全文 >>

文档排行