您的位置:首页 > 数据库

数据库 入门知识

2014-01-07 18:49 288 查看
1.数据库后缀名是自定义的
student.sqlite3,ldci.db

2.SQL语句是以;结束的
指令:.database ---查看数据库
          .tables ---查看所有表
3.主键:primary key
   自增长主键:integer primary key
4.
创建数据库:sqlite3 ldci.db
查看数据库:.database
创建表SQL语句:create table student(id integer primary key,name text,age text)
查看表的命令:.tables
显示表结构:  .schema 
表名

增加数据SQL语句:(两种插入方法)
insert into student(name,age) values('罗浩','18');
insert into student values('2','张三','19');

查询数据SQL语句:
select * from student; ---查询所有
select * from student where id=2; ---查询序号等于2的人
select * from student order by age; ---根据年龄排序(小到大)
select * from student order by age desc; ---根据年龄排序(大到小)

修改数据SQL语句:
update student set age=30 where id =1;

删除数据SQL语句:
delete from student where id=1;

defaults write com.apple.finder Appleshowallfiles -bool true ---显示隐藏文件夹 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: