MySQL基础操作

80 阅读1分钟

1. 数据库表创建删除

创建库

create database 数据库名;

删除库

drop database 数据库名;

选择数据库

use 数据库名

创建表

create table 数据表名;

删除表

drop database 数据库名;

2.字符串类型

image.png

3.数据表的增删改查

插入数据

insert into 数据表名 (类型名1,类型名2,类型名3) values

(数据1,数据2,数据3);

查看数据表

select * from 数据表名;

个别数据查询

select * from 数据表名 where 类型名='数据';

实例

image.png

image.png

更新数据

update 数据表名 set 类型名='新数据' where 数据名='数据';

image.png

删除数据

delete from 数据表名 where 数据名='数据';

image.png

查看数据结构

show databases;

show tables;

show columns from 数据表名;

image.png

数据表字段删、增、改

alter table 数据表名 drop 数据名;

image.png

alter table 数据表名 add 数据名 数据类型;

image.png

alter table 数据表名 modify 数据名 数据类型;

image.png

修改表名

alter table 数据表名 rename to 新数据表名;

image.png