sqlite(5)-select语句

语法##

SELECT column1, column2, columnN FROM table_name;
SELECT * FROM table_name;

实例##

假设数据

IDNAMEAGEADDRESSSALARY
1Paul32California20000.0
2Allen25Texas15000.0
3Teddy23Norway20000.0
4Mark25Rich-Mond65000.0
5David27Texas85000.0
6Kim22South-Hall45000.0
7James24Houston10000.0

格式化显示##

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

输入语句

SELECT ID, NAME, SALARY FROM COMPANY;

上面查询会产生以下结果:

|ID NAME | SALARY
|:———-| :———- |:———-|
|1 | Paul | 20000.0|
|2 | Allen | 15000.0|
|3 | Teddy | 20000.0|
|4 | Mark | 65000.0|
|5 | David | 85000.0|
|6 | Kim |45000.0|
|7 | James | 10000.0|

设置输出列的宽度##

sqlite>.width 10, 20, 10
sqlite>SELECT * FROM COMPANY;

.width 第一列10, 第二列20, 第三列10, 以下结果

    原文作者:Flannery
    原文地址: https://www.jianshu.com/p/847882573d8d
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞