sqlite3 命令

前端之家收集整理的这篇文章主要介绍了sqlite3 命令前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1:创建数据库

$sqlite3 testDB.db
sqlite version 3.7.15.2 2013-01-09 11:53:05
Enter ".help" for instructions
Enter sql statements terminated with a ";"
sqlite>


2.查看数据库

sqlite>.databases
seq name file
--- --------------- ----------------------
0 main /home/sqlite/testDB.db

3.退出
sqlite>.quit


4.dump 命令

$sqlite3 testDB.db .dump > testDB.sql

$sqlite3 testDB.db < testDB.sql
5.创建表

CREATE TABLE testDB.COMPANY(
ID INT PRIMARY KEY NOT NULL,
NAME TEXT NOT NULL,
AGE INT NOT NULL,
ADDRESS CHAR(50),
SALARY REAL
);

6.查看表信息

sqlite>.tables
COMPANY

表的完整信息

sqlite>.schema COMPANY
7.删除

sqlite>DROP TABLE COMPANY;

8.插入查询

INSERT INTO TABLE_NAME (column1,column2,column3,...columnN)]
VALUES (value1,value2,value3,...valueN);
表已经存在直接插入即可
INSERT INTO TABLE_NAME VALUES (value1,value2value3valueN);
或者拷贝其他的表
INSERT INTO first_table_name [(column1,... columnN)]
SELECT column1,...columnN
FROM second_table_name
[WHERE condition];

9.select查询

sqlite>.header on
sqlite>.mode column
sqlite> SELECT * FROM COMPANY;


10.运算符(算数/比较/逻辑/位/)

放在where中的条件

SELECT * FROM COMPANY WHERE SALARY > 50;


11.更新

sqlite> update company set address = 'LISTRON' WHERE ID = '7';


12.删除

sqlite> DELETE FROM COMPANY WHERE ID=7;


13.like子句

sqlite> SELECT * FROM COMPANY WHERE ADDRESS LIKE '%-%';

14.

太多了,没时间整了,以后继续。
参考http://www.yiibai.com/sqlite/sqlite_glob_clause.html
原文链接:https://www.f2er.com/sqlite/198495.html

猜你在找的Sqlite相关文章