Android学习-mysql 数据库基础语句

今天是2016年8月02日

mysql 数据库的增删改查操作

 

 

部门表1-1


 

 

职务表 1-2

 

     

 

 

用户表 1-3

 

创建表:

 

部门表

CREATE TABLE `dept` (

  `id` int(11) NOT NULL AUTO_INCREMENT,

  `num` int(11) DEFAULT NULL,

  `name` varchar(20) DEFAULT NULL,

  `address` varchar(20) DEFAULT NULL,

  PRIMARY KEY (`id`)

)

 

职务表:

CREATE TABLE `duty` (

  `id` int(4) NOT NULL AUTO_INCREMENT,

  `num` int(4) NOT NULL,

  `name` varchar(20) DEFAULT NULL,

  `low` varchar(10) DEFAULT NULL,

  `high` varchar(10) DEFAULT NULL,

  PRIMARY KEY (`id`)

)

 

用户表:

CREATE TABLE `login` (

  `id` decimal(4,0) NOT NULL DEFAULT '0',

  `userName` varchar(20) DEFAULT NULL,

  `password` varchar(20) DEFAULT NULL,

  PRIMARY KEY (`id`)

)

 

 

 

 

删除表:

Drop  table  + 表名

 

Drop table duty

 

Drop table dept

 

Drop table login

 

 

向表中插入数据

 

Insert into duty(num,name,low,high) values(‘数据1’,‘数据1’,‘数据1’,‘数据1’);

 

更新表数据

 

Update duty set name =’更改的名称’ where num =1;

 

更新多个字段

 

Update duty set name =’更改的名称’ , low=4500 where num =1;

 

 

删除表数据

 

Delete  from duty where num=1;

 

查询数量

Select count(num) from duty

 

 

 


posted on 2016-08-06 17:34  记住我叫王凯  阅读(253)  评论(0编辑  收藏  举报

导航