mysql 简单使用
来源:互联网 发布:淘宝食品企业店铺 编辑:程序博客网 时间:2024/06/06 20:10
Mysql使用(下载mysql workbench 工具,官方下载)
1. 登录:mysql –u root –p
2. 创建数据库 create database donwu
3. 使用数据库 use donwu;
4. 创建表 :createtable 表名称(列声明);
create table students(
id int unsigned not nullauto_increment primary key,
name char(8) not null,
sex char(4) not null,
age tinyint unsigned not null,
tel char(13) null default"-"
);
5. 插入表
insert [into] 表名 [(列名1,列名2,列名3, ...)] values (值1,值2,值3, ...);
insert into students values(NULL, "王刚", "男", 20, "13811371377");
6. 查询:
select name, age from students;
select * from students where age > 21;
select * from students where name like "%王%";
7. 更新表:
update 表名称 set列名称=新值 where更新条件;
updatestudents set tel=default where id=5;
updatestudents set age=age+1;
8. 删除表:
delete from 表名称 where删除条件;
deletefrom students where id=2;
deletefrom students where age<20;
9. 修改表:
1) 添加列:
altertable students add address char(60);
2) 修改列:
altertable students change name name char(16) not null;
将 name 列的数据类型改为char(16)
3) 删除列:
alter table 表名 drop列名称;
altertable students drop birthday;
4) 重命名:
alter table 表名 rename新表名;
altertable students rename workmates;
5) 删除表:
drop table 表名;
droptable workmates;
6) 删除数据库:
drop database 数据库名;
dropdatabase samp_db;
- mysql简单使用
- MySQL简单使用小结
- mysql简单的使用
- mysql的简单使用
- MySQL 简单使用
- mysql简单安装使用
- MySql简单sql使用
- MySQL简单使用
- MySQL简单使用
- mysql 简单使用
- MySQL触发器简单使用
- mysql的简单使用
- MySql语句简单使用
- mysql的简单使用
- mysql 触发器简单使用
- Mysql触发器简单使用
- Mysql简单使用
- MySQL简单使用
- Python xlrd/xlwt对excel进行操作
- LeetCode 334. Increasing Triplet Subsequence(长度为3的递增子序列)
- ffmpeg ffserver 作为 rtsp 服务器
- 关于sql 语句求平均值和总和
- 杂
- mysql 简单使用
- JSPatch 实现原理详解
- Jquery层叠选择器
- ireport 序号 自动增加
- XlsxExcel导出工具XlsxExcelUtils
- 总结近两个月出的BUG
- css3 box-orient box-pack box-align
- 实现简易秒表功能
- java reflect 给对象赋值