首页 > 数据库 >SQLite库笔记:命令行shell

SQLite库笔记:命令行shell

时间:2024-08-02 19:59:03浏览次数:12  
标签:... SQLite shell off 命令行 Show FILE SQL output

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页并查看页面缓存大小:

标签:...,SQLite,shell,off,命令行,Show,FILE,SQL,output
From: https://blog.csdn.net/starlight_0/article/details/140806783

相关文章

  • SQLite库笔记:下载编译
    SQLite是一个C语言库,它实现了一个小型、快速、自包含、高可靠性、全功能的SQL数据库引擎。它广泛应用于计算机、手机和嵌入式设备。SQLite源代码在公有领域(publicdomain),据SQLite官网介绍说可以免费使用,不需要license。1.源码包下载https://www.sqlite.org/download.html2.......
  • linux shell学习(上)
    第一个shell脚本打开文本编辑器(可以使用vi/vim命令来创建文件),新建一个文件test.sh,扩展名为sh(sh代表shell),扩展名并不影响脚本执行,见名知意就好,如果你用php写shell脚本,扩展名就用php好了。输入一些代码,第一行一般是这样:实例#!/bin/bashecho"HelloWorld!"#......
  • linux shell 写的一个小玩意(bash含99乘法表和计算器)
     esac.sh 主页面#!/bin/shwhile:do    echo"***********************************"    echo"*                *"    echo"*  输入你想要点的妹妹:1-3号 *"    echo"*    ......
  • windows 命令行 pip 安装报错
    pipinstalltkWARNING:Retrying(Retry(total=4,connect=None,read=None,redirect=None,status=None))afterconnectionbrokenby'ProxyError('Cannotconnecttoproxy.',OSError(0,'Error'))':/simple/tk/WARNING:Retrying(R......
  • 在cmd/powershell中使用java/javac -cp/--class-path命令链接多个jar包
    ​ 之前使用ide,习惯了傻瓜式一键运行java文件,对于java虚拟机以及java指令了解的很少,最近重温java,在使用windows中的cmd来运行java项目时,遇到了一点问题,相同的指令在cmd中能够运行,在powershell中不能正确运行,在国内网站上搜索无果后,果断去国外,在stackoverflow上找到解决办法。​ ......
  • 【反向Shell命令】集合
    ❝本指南提供了多种方法来建立反向Shell,包括使用加密和明文方式,适用于不同的场景和需求。通过这些技术,安全专家和合法授权的渗透测试者可以有效地控制远程系统,进行安全测试和漏洞评估。gs-netcat提供加密的反向Shell,支持文件传输和管理员登录警报。Bash和cURL方......
  • C高级(3):shell脚本
    目录1shell的基础概念:1.1概念1.2创建和执行2变量2.1用户自定义变量2.2位置变量2.3预定义变量2.4环境变量3功能语句3.1说明性语句3.2功能性语句1)read2)expr3)let4结构性语句4.1if语句4.2case语句4.3for循环4.4while4.5循环控制语句1shell的基础概念:1.1概......
  • TpmVscMgr.exe 命令行工具让具有管理凭据的用户能够在计算机上创建和删除 TPM 虚拟智
     tpmvscmgr|MicrosoftLearn tpmvscmgr命令行工具让具有管理凭据的用户能够在计算机上创建和删除TPM虚拟智能卡。 tpmvscmgrTpmVscMgr.exe 命令:    create        [/quiet]        /name<名称>       ......
  • Shell入门(保姆级教学)
    Shell是一种命令行解释器,也是一种脚本语言,广泛应用于Unix和类Unix系统中,例如Linux。它是用户与操作系统内核交互的桥梁,通过Shell可以执行系统命令、管理文件系统、处理文本数据等。本文将带你入门Shell编程,涵盖基础的语法、常用命令和一些实用技巧。Shell编程跟JavaScript、......
  • 如何通过PowerShell批量修改O365用户的office phone属性值
    我的博客园:https://www.cnblogs.com/CQman/如何通过PowerShell批量修改O365用户的officephone属性值?需求信息: 组织中的O365用户在创建时,已手动录入了办公电话(Officephone),现在需要在办公电话前面加上统一的数字,如“0571-0985”,以批量的方式统一修改。备注:O365用户的Offic......