美文网首页
mysql数据库基础

mysql数据库基础

作者: Challis | 来源:发表于2018-12-08 11:28 被阅读0次
# 查看所有的数据库
show databases;

# 创建数据库
create database test charset=utf8;

# 删除数据库,需要先退出当前这个数据库
drop database test;

# 选择数据库
use test;

# 展示当前表格
show tables;

# 创建表格
create table student(id int primary key auto_increment, name varchar(20) not null default '张三', age int not null default '20';

# 删除表格
drop table student;

# 修改表名
alter table student rename example;

# 增加字段
alter table student add score int not null default '100';

# 删除字段
alter table student drop sex;

# 修改字段
alter table student change name name varchar(10) default '李四';

对数据的增删改查

# 插入数据
insert into student(id, name, sex, score) values(null, '王五', '女', 100);

# 一次插入多条数据
insert into student(id, name, sex, score) values(null, '王五', '男', 200), (null, '赵六', '男', 55);

# 修改数据
update student set name='小王' where id = 3;

# 删除数据
delete from student where sex='女';

数据查询

select * from student;

# 多表查询
# 省略

SELECT 列名 FROM 表名 [WHERE --> GROUP BY -->HAVING--> ORDER BY]

相关文章

  • 2018-04-09 数据仓库技能要求

    一、基础技能1 关系数据库基础1.1. 关系数据库-mysql1.1.1 mysql 应用1.1.2 mysql ...

  • mysql基础语法,常用操作及概念

    mysql基础 数据库的好处 数据库相关概念 数据库存储数据的特点 MySQL产品的介绍和安装 MySQL服务的启...

  • MySQL性能调优与架构设计 - 简朝阳.mobi

    【下载地址】 本书以 MySQL 数据库的基础及维护(基础篇)为切入点,重点介绍了 MySQL 数据库应用系统的性...

  • MySQL(Mariadb)总结 - 目录

    关系型数据库基础概览Mysql(Mariadb)总结1 - 基础知识MySQL(Mariadb)总结2 - SQL...

  • Mysql数据库操作

    Mysql 基础 /************ * 数据库 * ************/ 1.连接数据库 mysq...

  • PHP全栈学习笔记5

    php与mysql数据库,PHP支持很多数据库,与mysql为牛逼组合,mysql数据库的基础知识的掌握是由必要的...

  • PHP全栈学习笔记5

    php与mysql数据库,PHP支持很多数据库,与mysql为牛逼组合,mysql数据库的基础知识的掌握是由必要的...

  • MySQL 基础

    本周继续学习 MySQL 基础 MySQL是一种开放源代码的关系型数据库管理系统(RDBMS),MySQL数据库系...

  • mysql基础

    mysql添加外键的4种方式 MySQL基础考点1 MySQL基础考点2 MySQL数据库六大设计规范总结1 My...

  • php-mysql笔记(二)

    http://www.runoob.com/mysql/mysql-tutorial.html 数据库基础 MyS...

网友评论

      本文标题:mysql数据库基础

      本文链接:https://www.haomeiwen.com/subject/oqofhqtx.html