您的位置:首页 > 数据库

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

2012-07-10 16:42 197 查看
.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: "/"

width:

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命令。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: