当前位置: 首页 > news >正文

SQLite库笔记:命令行shell

SQLite项目提供了一个简单的命令行程序sqlite3,它允许用户对SQLite数据库手动输入和执行SQL语句。更多详情可参考官网(https://www.sqlite.org/cli.html)。

  • help

        SQLite shell命令的help信息如下:

.auth ON|OFF             Show authorizer callbacks
.backup ?DB? FILE        Backup DB (default "main") to FILE
.bail on|off             Stop after hitting an error.  Default OFF
.cd DIRECTORY            Change the working directory to DIRECTORY
.changes on|off          Show number of rows changed by SQL
.check GLOB              Fail if output since .testcase does not match
.clone NEWDB             Clone data into NEWDB from the existing database
.connection [close] [#]  Open or close an auxiliary database connection
.databases               List names and files of attached databases
.dbconfig ?op? ?val?     List or change sqlite3_db_config() options
.dbinfo ?DB?             Show status information about the database
.dump ?OBJECTS?          Render database content as SQL
.echo on|off             Turn command echo on or off
.eqp on|off|full|...     Enable or disable automatic EXPLAIN QUERY PLAN
.excel                   Display the output of next command in spreadsheet
.exit ?CODE?             Exit this program with return-code CODE
.expert                  EXPERIMENTAL. Suggest indexes for queries
.explain ?on|off|auto?   Change the EXPLAIN formatting mode.  Default: auto
.filectrl CMD ...        Run various sqlite3_file_control() operations
.fullschema ?--indent?   Show schema and the content of sqlite_stat tables
.headers on|off          Turn display of headers on or off
.help ?-all? ?PATTERN?   Show help text for PATTERN
.import FILE TABLE       Import data from FILE into TABLE
.indexes ?TABLE?         Show names of indexes
.intck ?STEPS_PER_UNLOCK?  Run an incremental integrity check on the db
.limit ?LIMIT? ?VAL?     Display or change the value of an SQLITE_LIMIT
.lint OPTIONS            Report potential schema issues.
.load FILE ?ENTRY?       Load an extension library
.log FILE|on|off         Turn logging on or off.  FILE can be stderr/stdout
.mode MODE ?OPTIONS?     Set output mode
.nonce STRING            Suspend safe mode for one command if nonce matches
.nullvalue STRING        Use STRING in place of NULL values
.once ?OPTIONS? ?FILE?   Output for the next SQL command only to FILE
.open ?OPTIONS? ?FILE?   Close existing database and reopen FILE
.output ?FILE?           Send output to FILE or stdout if FILE is omitted
.parameter CMD ...       Manage SQL parameter bindings
.print STRING...         Print literal STRING
.prompt MAIN CONTINUE    Replace the standard prompts
.quit                    Stop interpreting input stream, exit if primary.
.read FILE               Read input from FILE or command output
.recover                 Recover as much data as possible from corrupt db.
.restore ?DB? FILE       Restore content of DB (default "main") from FILE
.save ?OPTIONS? FILE     Write database to FILE (an alias for .backup ...)
.scanstats on|off|est    Turn sqlite3_stmt_scanstatus() metrics on or off
.schema ?PATTERN?        Show the CREATE statements matching PATTERN
.separator COL ?ROW?     Change the column and row separators
.sha3sum ...             Compute a SHA3 hash of database content
.shell CMD ARGS...       Run CMD ARGS... in a system shell
.show                    Show the current values for various settings
.stats ?ARG?             Show stats or turn stats on or off
.system CMD ARGS...      Run CMD ARGS... in a system shell
.tables ?TABLE?          List names of tables matching LIKE pattern TABLE
.timeout MS              Try opening locked tables for MS milliseconds
.timer on|off            Turn SQL timer on or off
.trace ?OPTIONS?         Output each SQL statement as it is run
.version                 Show source, library and compiler versions
.vfsinfo ?AUX?           Information about the top-level VFS
.vfslist                 List all available VFSes
.vfsname ?AUX?           Print the name of the VFS stack
.width NUM1 NUM2 ...     Set minimum column widths for columnar output
  • SQL语句 

        执行sqlite3二进制文件(编译源码包所生成),键入SQL语句示例如下,创建表、插入数据、查询数据并按日期顺序排列:

        如上,可以通过“.table”命令查看数据库文件中的表。另外,可以通过“.schema”命令显示数据库的完整架构。

  • 页面缓存 

        以下命令可以查看或暂时设置在内存中页面缓存的最大尺寸。其中pages值表示在缓存中的页面数。内置页面缓存的默认大小为 2000 页,最小尺寸为 10 页。一页表示1K。

pragma cache_size;
pragma cache_size = pages;

        例如设置1000页并查看页面缓存大小:

相关文章:

  • 北京网站建设多少钱?
  • 辽宁网页制作哪家好_网站建设
  • 高端品牌网站建设_汉中网站制作
  • JavaScript基础——JavaScript调用的三种方式
  • 在Windows系统上生成SSH秘钥
  • frp的配置参考
  • Vue前端的安全
  • 无人机环保行业解决方案-应急环境污染处理
  • 简站WordPress主题 专业的WordPress建站服务商
  • 第十九次(安装nginx代理tomcat)
  • RabbitMQ发送者重连、发送者确认
  • 用于自动驾驶的基于立体视觉的语义 3D 对象和自我运动跟踪
  • 区间预测 | 光伏出力的区间预测(Matlab)
  • android前台服务
  • Python * attr方法
  • MVC 参考手册
  • 深入解析JVM垃圾回收机制:Full GC、Minor GC与Major GC
  • 【海外高校联合支持举办 | 学术大咖fellow汇聚】2024年人工智能与数字化管理国际会议(ICAIDM 2024,9月20-22)
  • [译] 怎样写一个基础的编译器
  • 【vuex入门系列02】mutation接收单个参数和多个参数
  • 2017 年终总结 —— 在路上
  • CSS 提示工具(Tooltip)
  • Essential Studio for ASP.NET Web Forms 2017 v2,新增自定义树形网格工具栏
  • Java|序列化异常StreamCorruptedException的解决方法
  • JavaScript创建对象的四种方式
  • JS 面试题总结
  • PhantomJS 安装
  • SOFAMosn配置模型
  • SpringCloud(第 039 篇)链接Mysql数据库,通过JpaRepository编写数据库访问
  • 前端工程化(Gulp、Webpack)-webpack
  • 400多位云计算专家和开发者,加入了同一个组织 ...
  • ​LeetCode解法汇总2583. 二叉树中的第 K 大层和
  • ​用户画像从0到100的构建思路
  • !$boo在php中什么意思,php前戏
  • #QT项目实战(天气预报)
  • #我与Java虚拟机的故事#连载01:人在JVM,身不由己
  • (02)Cartographer源码无死角解析-(03) 新数据运行与地图保存、加载地图启动仅定位模式
  • (vue)el-tabs选中最后一项后更新数据后无法展开
  • (分享)一个图片添加水印的小demo的页面,可自定义样式
  • (附源码)spring boot基于Java的电影院售票与管理系统毕业设计 011449
  • (附源码)ssm高校实验室 毕业设计 800008
  • (六)Flink 窗口计算
  • (三)Hyperledger Fabric 1.1安装部署-chaincode测试
  • (一)SvelteKit教程:hello world
  • *Django中的Ajax 纯js的书写样式1
  • .NET/C# 项目如何优雅地设置条件编译符号?
  • .NET程序集编辑器/调试器 dnSpy 使用介绍
  • @DateTimeFormat 和 @JsonFormat 注解详解
  • @EnableWebSecurity 注解的用途及适用场景
  • @WebService和@WebMethod注解的用法
  • [ A*实现 ] C++,矩阵地图
  • []T 还是 []*T, 这是一个问题
  • [023-2].第2节:SpringBoot中接收参数相关注解
  • [100天算法】-不同路径 III(day 73)
  • [AHOI2009]中国象棋 DP,递推,组合数
  • [BSidesCF 2019]Kookie1
  • [C#学习笔记]Newtonsoft.Json
  • [C++][ProtoBuf][初识ProtoBuf]详细讲解