SQLITE入门逐步讲解SQLITE命令行(六)

  • .nullvalue STRING 用STRING代替null值显示,不难理解,就不再累述了。
  • .output FILENAME 设置把查询输出到文件,后面的输出结果都保存到文件中,如:
    sqlite> .mode list
    sqlite> .output websites.txt
    sqlite> select * from websites;
    sqlite>
    可以在F盘下发现建立了websites.txt文件,其内容如下:
    1|CTOChina.net
    2|搜狐
    3|雅虎
    4|开源
    5|技术
  • .output stdout 设置把查询结果输出到屏幕,这是默认输出方式。如:
    sqlite> .output stdout
    sqlite> select * from websites;
    1|CTOChina.net
    2|搜狐
    3|雅虎
    4|开源
    5|技术
    sqlite>
  • .prompt MAIN CONTINUE Replace the standard prompts(修改提示符)请补充?
  • .quit 退出SQLite程序,同.exit命令
  • .read FILENAME Execute SQL in FILENAME 执行文件中的SQL语句,文件中的语句一定要带上分号(;).
    我们在F盘下建sqldata.txt文件,其内容为:
    insert into websites(WebName) values('测试插入数据0');
    insert into websites(WebName) values('测试插入数据1');
    select * from websites;
    我们执行.read命令如下:
    sqlite> .read sqldata.txt
    1|CTOChina.net
    2|搜狐
    3|雅虎
    4|开源
    5|技术
    6|测试插入数据0
    7|测试插入数据1
    sqlite>
  • .schema ?TABLE? Show the Create statements 以SQL格式输出表结构,如:
    sqlite> .schema websites
    CREATE TABLE [websites] (
    [WebID] INTEGER NOT NULL PRIMARY KEY,
    [WebName] VARCHAR(20) NULL
    );
    CREATE INDEX mytestindex on websites([webID]);
    sqlite>
  • .separator STRING Change separator used by output mode and .import 修改分隔符,如:
    sqlite> select * from websites limit 4;
    1|CTOChina.net
    2|搜狐
    3|雅虎
    4|开源
    sqlite> .separator /
    sqlite> select * from websites limit 4;
    1/CTOChina.net
    2/搜狐
    3/雅虎
    4/开源
    sqlite>
  • .show Show the current values for various settings 显示配置信息,如:
    sqlite> .show
    echo: off
    explain: off
    headers: off
    mode: list
    nullvalue: ""
    output: stdout
    separator: "/"

    sqlite>
  • .tables ?PATTERN? List names of tables matching a LIKE pattern 显示库中表的列表。
  • .timeout MS Try opening locked tables for MS milliseconds 超时时间,单位:毫秒
  • .width NUM NUM ... Set column widths for "column" mode 设置列宽,举例见上文.explain命令。
出处:http://www.zhaiqianfeng.com    
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
原文地址:https://www.cnblogs.com/zhaiqianfeng/p/4616843.html