码迷,mamicode.com
首页 > 数据库 > 详细

创建SQL语句_面试

时间:2017-08-09 21:07:38      阅读:141      评论:0      收藏:0      [点我收藏+]

标签:一个   table   auto   pop   属性   pos   content   不同   drop   

创建一个表:create table if not exists Teachaers(tea_id integer  primary key autoincrement,tea_name text,tea_gender text,tea_age interger,tea_salary text)

primary key  主键


create table if not exists Teachaers(tea_id integer  primary key autoincrement,tea_name text,tea_gender text,tea_age interger,tea_salary text)primary key  主键  区分每一条数据,因此在开发中主键的值是唯一的,不同意有同样的两个值存在.  autoincrement自增   修饰的属性值在每一次数据添加时值就会自己主动添加一.

插入数据:insert into Teachaers(tea_name ,tea_gender,tea_age,tea_salary)values("xx","x",20,xxxx)


查询数据


查询全部的数据:select * from Teachaers


查询某一条数据:select * from Teachaers where tea_id = 2


查询多个条件的数据:select * from Teachaers where tea_gender = "女" and tea_age = 25


查询部分数据:select tea_name ,tea_salary from Teachaers  where tea_id = 2


删除表中某一个元素:delete from Teachaers where tea_id = 2


更新数据库某一条的某一个部分

update Teachaers set tea_name = "蔡cai" ,tea_age =27  where tea_salary = 130000


删除表格

drop table 表名


创建SQL语句_面试

标签:一个   table   auto   pop   属性   pos   content   不同   drop   

原文地址:http://www.cnblogs.com/wzzkaifa/p/7327386.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!