SQLite 基础11

2021-12-01 17:28:30 浏览数 (1)

再进行查询

代码语言:javascript复制
sqlite> select * from company;
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> 

格式明显变工整了

代码语言:javascript复制
sqlite> select name,salary,id from company;
name        salary      id        
----------  ----------  ----------
Paul        20000.0     1         
Allen       15000.0     2         
Teddy       20000.0     3         
Mark        65000.0     4         
David       85000.0     5         
Kim         45000.0     6         
James       10000.0     7         
sqlite> 

设置列宽

代码语言:javascript复制
sqlite> .width 6 , 15, 10
sqlite> select name,salary,id from company;
name    salary      id             
------  ----------  ---------------
Paul    20000.0     1              
Allen   15000.0     2              
Teddy   20000.0     3              
Mark    65000.0     4              
David   85000.0     5              
Kim     45000.0     6              
James   10000.0     7              
sqlite>

隐藏的信息管理表

代码语言:javascript复制
sqlite> .schema sqlite_master
CREATE TABLE sqlite_master (
  type text,
  name text,
  tbl_name text,
  rootpage integer,
  sql text
);
sqlite> 

这张表里包含了其它表的信息

代码语言:javascript复制
sqlite>  select * from sqlite_master;
type        name        tbl_name    rootpage    sql                                                         
----------  ----------  ----------  ----------  ------------------------------------------------------------
table       test        test        2           CREATE TABLE test ( id int primary key not null, name text )
index       sqlite_aut  test        3                                                                       
table       hello       hello       6           CREATE TABLE hello (
id int primary key not null,
age int,
n
index       sqlite_aut  hello       7                                                                       
table       ui          ui          8           CREATE TABLE ui(
id int,
name text,
age int)                
table       company     company     9           CREATE TABLE company(
id int primary key not null,
name text
index       sqlite_aut  company     10                                                                      
table       department  department  11          CREATE TABLE department(
id int primary key not null,
dept c
index       sqlite_aut  department  12                                                                      
sqlite> 

0 人点赞