一个小时内学习SQLite数据库

发表于:2014-7-17 10:54

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:bobird    来源:51Testing软件测试网采编

分享:
  .mode column 将设置为列显示模式,.header 将显示列名。
  修改表结构,增加列:
  sqlite> alter table mytable add column email text not null '' collate nocase;;
  创建视图:
  sqlite> create view nameview as select * from mytable;
  创建索引:
  sqlite> create index test_idx on mytable(value);
  4. 一些有用的 SQLite 命令
  显示表结构:
  sqlite> .schema [table]
  获取所有表和视图:
  sqlite > .tables
  获取指定表的索引列表:
  sqlite > .indices [table ]
  导出数据库到 SQL 文件:
  sqlite > .output [filename ]
  sqlite > .dump
  sqlite > .output stdout
  从 SQL 文件导入数据库:
  sqlite > .read [filename ]
  格式化输出数据到 CSV 格式:
  sqlite >.output [filename.csv ]
  sqlite >.separator ,
  sqlite > select * from test;
  sqlite >.output stdout
  从 CSV 文件导入数据到表中:
  sqlite >create table newtable ( id integer primary key, value text );
  sqlite >.import [filename.csv ] newtable
  备份数据库:
  /* usage: sqlite3 [database] .dump > [filename] */
  sqlite3 mytable.db .dump > backup.sql
  恢复数据库:
  /* usage: sqlite3 [database ] < [filename ] */
  sqlite3 mytable.db < backup.sql
22/2<12
重磅发布,2022软件测试行业现状调查报告~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计

法律顾问:上海漕溪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2023
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号