SQLite基础操作
来源:互联网 发布:avast知乎 编辑:程序博客网 时间:2024/06/06 08:45
1.SQLite环境配置
下载SQLite(http://www.sqlite.org/download.html)
解压出来后,得到文件sqlite3.def、sqlite3.dll 和 sqlite3.exe
将存放SQLite文件目录添加到环境变量PATH路径下
2.测试环境
C:\Users\Administrator>cd C:\sqlite
C:\sqlite>sqlite3
SQLite version 3.7.5
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .show
echo: off
explain: off
headers: off
mode: list
nullvalue: ""
output: stdout
separator: "|"
stats: off
width:
sqlite> .schema sqlite_master
CREATE TABLE sqlite_master (
type text,
name text,
tbl_name text,
rootpage integer,
sql text
);
3.创建数据库
sqlite> test.db
4.创建表
sqlite> create table table_name(id integer primary key,value text);
CPU Time: user 0.000000 sys 0.000000
5.插入数据
sqlite> insert into table_name(id,value)values(XX,XXX);
6.查询数据
sqlite> select * from table_name where xx = xxx;
7.修改数据
sqlite>update table_name set xx = xxx where xx = xxx;
8.删除数据
sqlite>delete from table_name where xx = xxx;
9.修改表结构
sqlite>alter table table_name add column xxx;
10.创建视图
sqlite>create view view_name as select * from table_name;
11.创建索引
sqlite>create index idx_xxx on xxx(xxx);
12.显示表结构
sqlite> .schema [table_name];
13.显示所有的表和视图
sqlite > .tables;
14.显示指定表的索引列表
sqlite > .indices [table_name];
15.导出数据库到 SQL 文件:
sqlite > .output [file_name];
sqlite > .dump;
sqlite > .output file_name;
16.从 SQL 文件导入数据库:
sqlite > .read [file_name];
17.格式化输出数据到 CSV 格式:
sqlite >.output [file_name.csv];
sqlite >.separator;
sqlite > select * from table_name;
sqlite >.output file_name;
18.从 CSV 文件导入数据到表中:
sqlite >create table new_table(xx,xx);
sqlite >.import [file_name.csv ] new_table;
19.备份数据库:
/* usage: sqlite3 [database] .dump > [filename] */
sqlite3 mytable.db .dump > file_name.sql
20.恢复数据库:
/* usage: sqlite3 [database ] < [filename ] */
sqlite3 mytable.db < file_name.sql
下载SQLite(http://www.sqlite.org/download.html)
解压出来后,得到文件sqlite3.def、sqlite3.dll 和 sqlite3.exe
将存放SQLite文件目录添加到环境变量PATH路径下
2.测试环境
C:\Users\Administrator>cd C:\sqlite
C:\sqlite>sqlite3
SQLite version 3.7.5
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .show
echo: off
explain: off
headers: off
mode: list
nullvalue: ""
output: stdout
separator: "|"
stats: off
width:
sqlite> .schema sqlite_master
CREATE TABLE sqlite_master (
type text,
name text,
tbl_name text,
rootpage integer,
sql text
);
3.创建数据库
sqlite> test.db
4.创建表
sqlite> create table table_name(id integer primary key,value text);
CPU Time: user 0.000000 sys 0.000000
5.插入数据
sqlite> insert into table_name(id,value)values(XX,XXX);
6.查询数据
sqlite> select * from table_name where xx = xxx;
7.修改数据
sqlite>update table_name set xx = xxx where xx = xxx;
8.删除数据
sqlite>delete from table_name where xx = xxx;
9.修改表结构
sqlite>alter table table_name add column xxx;
10.创建视图
sqlite>create view view_name as select * from table_name;
11.创建索引
sqlite>create index idx_xxx on xxx(xxx);
12.显示表结构
sqlite> .schema [table_name];
13.显示所有的表和视图
sqlite > .tables;
14.显示指定表的索引列表
sqlite > .indices [table_name];
15.导出数据库到 SQL 文件:
sqlite > .output [file_name];
sqlite > .dump;
sqlite > .output file_name;
16.从 SQL 文件导入数据库:
sqlite > .read [file_name];
17.格式化输出数据到 CSV 格式:
sqlite >.output [file_name.csv];
sqlite >.separator;
sqlite > select * from table_name;
sqlite >.output file_name;
18.从 CSV 文件导入数据到表中:
sqlite >create table new_table(xx,xx);
sqlite >.import [file_name.csv ] new_table;
19.备份数据库:
/* usage: sqlite3 [database] .dump > [filename] */
sqlite3 mytable.db .dump > file_name.sql
20.恢复数据库:
/* usage: sqlite3 [database ] < [filename ] */
sqlite3 mytable.db < file_name.sql
0 0
- SQLite基础操作
- SQLite基础操作
- Python基础--python操作sqlite
- android基础入门SQLite数据库操作(15)
- sqlite 轻便型数据库基础操作
- FMDB基础(oc操作sqlite)
- python基础学习-python操作sqlite数据库
- SQLite:Java操作SQLite
- SQLite基础
- Sqlite 基础
- SQlite基础
- sqlite 基础
- Sqlite基础
- SQLite 基础
- SQLite基础
- Android平台学习基础(2)-SQLite基本操作
- android的基础学习:SQLite存储方式以及数据库操作
- [Android] SQLite数据库之增删改查基础操作
- Docker Orchestration
- Faster R-CNN WINDOWS CPU环境搭建(详细版)
- android 关于TextView getLineCount() 获得的值始终为0问题
- 43. Multiply Strings 大数相乘 leetcode
- Syntax Error, parameterized types are only if source level is 1.5处理
- SQLite基础操作
- 关于js number 的精度问题
- spymemcached和xmemcached的性能对比
- 分冶算法思想
- liunx 安装mysql
- YAF 框架的皮毛
- Linux中eval用法
- ARM9嵌入式系统设计(基于S3C2410与Linux)——第二篇ARM体系结构
- 全栈工程师之路(一)—— CSS(网页样式语言)