设为首页 加入收藏

TOP

mini2440上SQLite操作
2014-11-24 14:08:16 来源: 作者: 【 】 浏览:0
Tags:mini2440 SQLite 操作

(1)创建数据库文件test.db
[root@mini2440 /]#cd /home/www
#sqlite3 test.db
SQLite version 3.7.7.1 2011-06-28 17:39:05
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite>


(2)创建表
sqlite> create table students(id integer,name text,age integer);
sqlite> .tables
students
sqlite>


(3)删除表
sqlite> drop table students
sqlite> .tables
sqlite>


(4)查看表结构
sqlite> create table students(id integer,name text,age integer);
sqlite> .schema students
CREATE TABLE students(id integer,name text,age integer);
sqlite>


(5)插入列
sqlite> alter table students add cul;
sqlite> alter table students add column sex text;
sqlite> .schema students
CREATE TABLE students(id integer,name text,age integer, cul, sex text);
sqlite>


(6)插入表记录
sqlite> insert into students values(1,'aa',10,0,'m');
sqlite> insert into students values(2,'bb',11,1,'f');
sqlite> select * from students;
1|aa|10|0|m
2|bb|11|1|f
sqlite>


(7)重命名表
sqlite> alter table students rename to stu;
sqlite>


(8)删除某一列,这为列cul
sqlite> begin transaction;
sqlite> create temporary table stu_bak(id integer,name text,age integer,sex text);
sqlite> insert into stu_bak select id,name,age,sex from stu;
sqlite> drop table stu;
sqlite> create table stu(id integer,name text,age integer,sex text);
sqlite> insert into stu select id,name,age,sex from stu_bak;
sqlite> drop table stu_bak;
sqlite> select * from stu;
1|aa|10|m
2|bb|11|f
sqlite> commit;
sqlite>


(9)退出程序
sqlite> .quit
[root@mini2440 www]#


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Linux网络编程:线程池的使用 下一篇mni2440数据库SQLite编程练习

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: