sqlite> create table bird (id integer primary key autoincrement not null,swing int);//创建一个新表,id是整数,自增和主键。
sqlite> .schema bird//查看表的架构
CREATE TABLE bird (id integer primary key autoincrement not null,swing int);
sqlite> insert into bird(swing) values(abs(random())%100);//插入一条新记录,因为id是自增所以只赋值swing字段即可,使用每次一个100以内的随机数(绝对值)
sqlite> insert into bird(swing) values(abs(random())%100);
sqlite> insert into bird(swing) values(abs(random())%100);
sqlite> select * from bird;
id swing
---------- ----------
1 13
2 81
3 35
sqlite> alter table bird add column addr text default 'gd';//插入一个新列addr,类型是text,默认值是gd
sqlite> select * from bird;
id swing addr
---------- ---------- ----------
1 13 gd
2 81 gd
3 35 gd