基本语法:
create table用于在给定的数据库中创建新表。
CREATE TABLE database_name.table_name(
column1 datatype PRIMARY KEY(one or more columns),
column2 datatype,
column3 datatype,
.....
columnN datatype,
);
实例:
创建名为student
的表:
创建create_student.txt,里面的内容是:
create table student(
ID int primary key not NULL,
NAME TEXT NOT NULL,
AGE INT NOT NULL
);
利用前面所学的知识,像下面这样运行就可以了:
sqlite> .read create_student.txt
sqlite>
查看表:
使用 .table 来查看数据库中所有的表:
sqlite> .table
student
sqlite>
查看表的信息:
.schema: 此命令用了查看表的信息,得到创建表时的语句。
需要指定表的名字
sqlite> .schema student
CREATE TABLE student( -- 创建表 这个表示单行注释
ID int primary key not NULL, /* 这个是多行注释 */
NAME TEXT NOT NULL,
AGE INT NOT NULL
);
sqlite>