sqlite database used sql statements to create tables, add columns, random number random, increment defaults.

sqlite> create table bird (id integer primary key autoincrement not null, swing int); // create a new table, id is an integer, and increment primary key.
sqlite> .schema bird // Display schema
the CREATE TABLE Bird (Integer Primary Key ID AUTOINCREMENT Not null, Swing int);
SQLite> INSERT INTO Bird (Swing) values (ABS (Random ())% 100); // Insert a new record, because it is self-energizing id is assigned only to swing fields, each using a random number (absolute value) within a 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 is
2 81
. 3 35
SQLite> Table ALTER Bird the Add default text column addr 'Gd'; // insert a new column addr, type text, the default value is Gd
SQLite> SELECT * from Bird;
id          swing       addr
----------  ----------  ----------
1           13          gd
2           81          gd
3           35          gd

Published 45 original articles · won praise 1 · views 4063

Guess you like

Origin blog.csdn.net/talkingmute/article/details/104095028
Recommended