加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

SQLite3使用方法大全(一)之常用命令

发布时间:2020-12-12 19:39:09 所属栏目:百科 来源:网络整理
导读:前言 本小节主要涉及SQLite3常用命令,具体看下面表格。 SQLite3官网 命令 补充: **删除数据表:**sqlite3 drop table table_name; **删除索引:**sqlite3 drop index index_name; 举例 1. 创建一个表: sqlite create table test ( name text,age text,cla

前言

本小节主要涉及SQLite3常用命令,具体看下面表格。
SQLite3官网

命令



补充:

**删除数据表:**
sqlite3> drop table table_name;
**删除索引:**
sqlite3> drop index index_name;

举例

1. 创建一个表:

sqlite> create table test ( name text,age text,class integer );

2. 插入数据,显示,设置显示格式,重新显示:

sqlite3> insert into test values("jack","15",5);
sqlite3> select * from test;
结果:jack|15|5
/* 格式化输出 */
sqlite3> .header on
sqlite3> .mode column
sqlite3> select * from test;
结果:
name    age     class
---- ----- -----
jack    15        5

3. 如果有多个表,我们想将CREATE TABLE的命令全部保存成一个脚本,以供给其他数据库使用:

lu@lu~/test$ sqlite3 test.db ".schema" > create_test.sql
lu@lu~/test$ cat create_test.sql
结果:
create table test (
    name text,age text,class integer
);

4. 现在将生成的create_test.sql给另一个数据中创建表:

sqlite3> .read create_test.sql

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读