本次实验建立的数据库在下一个实验当中要用。
- 在Visual Free Basic根目录下打开命令行程序。
- 输入sqlite3 student.db。表示创建一个数据库名字叫student。(必须要有Sqlite3命令行工具,没有的话要下载,本教程开篇文章的链接中的软件包中附属了该工具)
- 进入数据库命令提示后:输入SQL语句:
create table stu(id integer,name text,gender text,age integer);表示创建一张表stu,有四个字段。
- 使用插入语句插入数据:
insert into stu (id, name, gender, age) values (1, '余星舟', '男', 19);
insert into stu (id, name, gender, age) values (2, '李云美', '女', 18);
insert into stu (id, name, gender, age) values (3, '张运恒', '男', 20);
insert into stu (id, name, gender, age) values (4, '郑小翠', '女', 18);
- 使用select * from stu;查询出刚刚插入的数据。
- 使用.tables查询当前数据库中有哪些表。
- 使用.open student.db可以打开数据库。
- 使用.quit退出。
本题建立的数据库在下一题中要使用。