语法##
SELECT column1, column2, columnN FROM table_name;
SELECT * FROM table_name;
实例##
假设数据
ID | NAME | AGE | ADDRESS | SALARY |
---|---|---|---|---|
1 | Paul | 32 | California | 20000.0 |
2 | Allen | 25 | Texas | 15000.0 |
3 | Teddy | 23 | Norway | 20000.0 |
4 | Mark | 25 | Rich-Mond | 65000.0 |
5 | David | 27 | Texas | 85000.0 |
6 | Kim | 22 | South-Hall | 45000.0 |
7 | James | 24 | Houston | 10000.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, 以下结果