库操作和表操作

一、库操作

1.新建数据库

语法:
create database 数据库名 charset utf8;

mysql> create database gao1 charset utf8;
Query OK, 1 row affected (0.00 sec)

2.查看数据库

查看所有的库:show databases;

show databases;

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| gao                |
| gao1               |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
6 rows in set (0.01 sec)

具体查看某个库:show create database 数据库名

mysql> show create database gao1;
+----------+---------------------------------------------------------------+
| Database | Create Database                                               |
+----------+---------------------------------------------------------------+
| gao1     | CREATE DATABASE `gao1` /*!40100 DEFAULT CHARACTER SET utf8 */ |
+----------+---------------------------------------------------------------+
1 row in set (0.00 sec)

查看当前所在的库:select database();

mysql> use gao1
Database changed
mysql> select database();
+------------+
| database() |
+------------+
| gao1       |
+------------+
1 row in set (0.00 sec)

3.使用库

use 数据库名

mysql> use gao
Database changed
mysql> select database();
+------------+
| database() |
+------------+
| gao        |
+------------+
1 row in set (0.00 sec)

4.删除数据库

drop database  数据库名;

mysql> drop database gao1;
Query OK, 0 rows affected (0.01 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| gao                |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.00 sec)

5.修改数据库

alter database 数据库名 charset 编码名

mysql> alter database gao charset gbk;
Query OK, 1 row affected (0.00 sec)

mysql> show create database gao;
+----------+-------------------------------------------------------------+
| Database | Create Database                                             |
+----------+-------------------------------------------------------------+
| gao      | CREATE DATABASE `gao` /*!40100 DEFAULT CHARACTER SET gbk */ |
+----------+-------------------------------------------------------------+
1 row in set (0.00 sec)

二、表操作

1、创建表

格式:

create table(

字段名1  类型[宽度,约束类型],

字段名2 类型[宽度,约束类型],

字段名3 类型[宽度,约束类型],

);

注意点:

1、同一个表中,字段名不能相同

2、宽度和约束类型是自己选择的

3、字段名和类型是必须的

mysql> use gao
Database changed
mysql> create table intforce(
    -> id int,
    -> name varchar(50),
    -> age int(3)
    -> );
Query OK, 0 rows affected (0.04 sec)

mysql> show tables;
+---------------+
| Tables_in_gao |
+---------------+
| intforce      |
| t1            |
| t2            |
| t3            |
| t4            |
| t5            |
| t6            |
+---------------+
7 rows in set (0.00 sec)

mysql> desc intforce
    -> ;
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| id    | int(11)     | YES  |     | NULL    |       |
| name  | varchar(50) | YES  |     | NULL    |       |
| age   | int(3)      | YES  |     | NULL    |       |
+-------+-------------+------+-----+---------+-------+
3 rows in set (0.02 sec)

2.查看表

show create table 表名; \G 可查看表详细结构

1、在当前数据库下

mysql> show create table intforce;
+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table    | Create Table                                                                                                                                              |
+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
| intforce | CREATE TABLE `intforce` (
  `id` int(11) DEFAULT NULL,
  `name` varchar(50) DEFAULT NULL,
  `age` int(3) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=gbk |
+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

2、在其他数据库下

[mysql> show create table mysql.user;
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table | Create Table                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| user  | CREATE TABLE `user` (
  `Host` char(60) COLLATE utf8_bin NOT NULL DEFAULT ‘‘,
  `User` char(32) COLLATE utf8_bin NOT NULL DEFAULT ‘‘,
  `Select_priv` enum(‘N‘,‘Y‘) CHARACTER SET utf8 NOT NULL DEFAULT ‘N‘,
  `Insert_priv` enum(‘N‘,‘Y‘) CHARACTER SET utf8 NOT NULL DEFAULT ‘N‘,
  `Update_priv` enum(‘N‘,‘Y‘) CHARACTER SET utf8 NOT NULL DEFAULT ‘N‘,
  `Delete_priv` enum(‘N‘,‘Y‘) CHARACTER SET utf8 NOT NULL DEFAULT ‘N‘,
  `Create_priv` enum(‘N‘,‘Y‘) CHARACTER SET utf8 NOT NULL DEFAULT ‘N‘,
  `Drop_priv` enum(‘N‘,‘Y‘) CHARACTER SET utf8 NOT NULL DEFAULT ‘N‘,
  `Reload_priv` enum(‘N‘,‘Y‘) CHARACTER SET utf8 NOT NULL DEFAULT ‘N‘,
  `Shutdown_priv` enum(‘N‘,‘Y‘) CHARACTER SET utf8 NOT NULL DEFAULT ‘N‘,
  `Process_priv` enum(‘N‘,‘Y‘) CHARACTER SET utf8 NOT NULL DEFAULT ‘N‘,
  `File_priv` enum(‘N‘,‘Y‘) CHARACTER SET utf8 NOT NULL DEFAULT ‘N‘,
  `Grant_priv` enum(‘N‘,‘Y‘) CHARACTER SET utf8 NOT NULL DEFAULT ‘N‘,
  `References_priv` enum(‘N‘,‘Y‘) CHARACTER SET utf8 NOT NULL DEFAULT ‘N‘,
  `Index_priv` enum(‘N‘,‘Y‘) CHARACTER SET utf8 NOT NULL DEFAULT ‘N‘,
  `Alter_priv` enum(‘N‘,‘Y‘) CHARACTER SET utf8 NOT NULL DEFAULT ‘N‘,
  `Show_db_priv` enum(‘N‘,‘Y‘) CHARACTER SET utf8 NOT NULL DEFAULT ‘N‘,
  `Super_priv` enum(‘N‘,‘Y‘) CHARACTER SET utf8 NOT NULL DEFAULT ‘N‘,
  `Create_tmp_table_priv` enum(‘N‘,‘Y‘) CHARACTER SET utf8 NOT NULL DEFAULT ‘N‘,
  `Lock_tables_priv` enum(‘N‘,‘Y‘) CHARACTER SET utf8 NOT NULL DEFAULT ‘N‘,
  `Execute_priv` enum(‘N‘,‘Y‘) CHARACTER SET utf8 NOT NULL DEFAULT ‘N‘,
  `Repl_slave_priv` enum(‘N‘,‘Y‘) CHARACTER SET utf8 NOT NULL DEFAULT ‘N‘,
  `Repl_client_priv` enum(‘N‘,‘Y‘) CHARACTER SET utf8 NOT NULL DEFAULT ‘N‘,
  `Create_view_priv` enum(‘N‘,‘Y‘) CHARACTER SET utf8 NOT NULL DEFAULT ‘N‘,
  `Show_view_priv` enum(‘N‘,‘Y‘) CHARACTER SET utf8 NOT NULL DEFAULT ‘N‘,
  `Create_routine_priv` enum(‘N‘,‘Y‘) CHARACTER SET utf8 NOT NULL DEFAULT ‘N‘,
  `Alter_routine_priv` enum(‘N‘,‘Y‘) CHARACTER SET utf8 NOT NULL DEFAULT ‘N‘,
  `Create_user_priv` enum(‘N‘,‘Y‘) CHARACTER SET utf8 NOT NULL DEFAULT ‘N‘,
  `Event_priv` enum(‘N‘,‘Y‘) CHARACTER SET utf8 NOT NULL DEFAULT ‘N‘,
  `Trigger_priv` enum(‘N‘,‘Y‘) CHARACTER SET utf8 NOT NULL DEFAULT ‘N‘,
  `Create_tablespace_priv` enum(‘N‘,‘Y‘) CHARACTER SET utf8 NOT NULL DEFAULT ‘N‘,
  `ssl_type` enum(‘‘,‘ANY‘,‘X509‘,‘SPECIFIED‘) CHARACTER SET utf8 NOT NULL DEFAULT ‘‘,
  `ssl_cipher` blob NOT NULL,
  `x509_issuer` blob NOT NULL,
  `x509_subject` blob NOT NULL,
  `max_questions` int(11) unsigned NOT NULL DEFAULT ‘0‘,
  `max_updates` int(11) unsigned NOT NULL DEFAULT ‘0‘,
  `max_connections` int(11) unsigned NOT NULL DEFAULT ‘0‘,
  `max_user_connections` int(11) unsigned NOT NULL DEFAULT ‘0‘,
  `plugin` char(64) COLLATE utf8_bin NOT NULL DEFAULT ‘mysql_native_password‘,
  `authentication_string` text COLLATE utf8_bin,
  `password_expired` enum(‘N‘,‘Y‘) CHARACTER SET utf8 NOT NULL DEFAULT ‘N‘,
  `password_last_changed` timestamp NULL DEFAULT NULL,
  `password_lifetime` smallint(5) unsigned DEFAULT NULL,
  `account_locked` enum(‘N‘,‘Y‘) CHARACTER SET utf8 NOT NULL DEFAULT ‘N‘,
  PRIMARY KEY (`Host`,`User`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT=‘Users and global privileges‘ |
+-------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.01 sec)

3、修改表结构

1、修改表名

alter table 表名 rename 新表名

如下图把表test1 改成 test2

mysql> show tables;
+---------------+
| Tables_in_gao |
+---------------+
| t1            |
| t2            |
| t3            |
| t4            |
| t5            |
| t6            |
| test1         |
+---------------+
7 rows in set (0.00 sec)

mysql> alter table test1 rename test2;
Query OK, 0 rows affected (0.00 sec)

mysql> show tables;
+---------------+
| Tables_in_gao |
+---------------+
| t1            |
| t2            |
| t3            |
| t4            |
| t5            |
| t6            |
| test2         |
+---------------+
7 rows in set (0.00 sec)

2、增加字段

alter table 表名 add 字段名 数据类型 【约束条件】

        add 字段名 数据类型 【约束条件】

add 字段名 数据类型 【约束条件】

mysql> alter table test2
    -> add money int(4) not null default 10,
    -> add place varchar(10) not null
    -> ;

mysql> desc test2;
+-------+-------------+------+-----+---------+-------+
| Field | Type        | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| id    | int(11)     | YES  |     | NULL    |       |
| name  | varchar(50) | YES  |     | NULL    |       |
| age   | int(3)      | YES  |     | NULL    |       |
| money | int(4)      | NO   |     | 10      |       |
| place | varchar(10) | NO   |     | NULL    |       |
+-------+-------------+------+-----+---------+-------+
5 rows in set (0.01 sec)

添加在某个字段后面

mysql> alter table test2
    -> add stu_name varchar(10) after name;
Query OK, 0 rows affected (0.03 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> desc test2;
+----------+-------------+------+-----+---------+-------+
| Field    | Type        | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| id       | int(11)     | YES  |     | NULL    |       |
| name     | varchar(50) | YES  |     | NULL    |       |
| stu_name | varchar(10) | YES  |     | NULL    |       |
| age      | int(3)      | YES  |     | NULL    |       |
| money    | int(4)      | NO   |     | 10      |       |
| place    | varchar(10) | NO   |     | NULL    |       |
+----------+-------------+------+-----+---------+-------+
6 rows in set (0.01 sec)

把字段加在第一个

mysql> alter table test2
    -> add stu_age int(2) first;
Query OK, 0 rows affected (0.03 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> desc test2;
+----------+-------------+------+-----+---------+-------+
| Field    | Type        | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| stu_age  | int(2)      | YES  |     | NULL    |       |
| id       | int(11)     | YES  |     | NULL    |       |
| name     | varchar(50) | YES  |     | NULL    |       |
| stu_name | varchar(10) | YES  |     | NULL    |       |
| age      | int(3)      | YES  |     | NULL    |       |
| money    | int(4)      | NO   |     | 10      |       |
| place    | varchar(10) | NO   |     | NULL    |       |
+----------+-------------+------+-----+---------+-------+
7 rows in set (0.00 sec)

3.删除字段

alter table 表名 drop 字段名

删除stu_age 字段

mysql> alter table test2
    -> drop stu_age;
Query OK, 0 rows affected (0.06 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> desc test2;
+----------+-------------+------+-----+---------+-------+
| Field    | Type        | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| id       | int(11)     | YES  |     | NULL    |       |
| name     | varchar(50) | YES  |     | NULL    |       |
| stu_name | varchar(10) | YES  |     | NULL    |       |
| age      | int(3)      | YES  |     | NULL    |       |
| money    | int(4)      | NO   |     | 10      |       |
| place    | varchar(10) | NO   |     | NULL    |       |
+----------+-------------+------+-----+---------+-------+
6 rows in set (0.00 sec)

4.修改字段

把id的类型改为int(8)

mysql> alter table test2
    -> modify id int(8);
Query OK, 0 rows affected (0.03 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> desc test2;
+----------+-------------+------+-----+---------+-------+
| Field    | Type        | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------+-------+
| id       | int(8)      | YES  |     | NULL    |       |
| name     | varchar(50) | YES  |     | NULL    |       |
| stu_name | varchar(10) | YES  |     | NULL    |       |
| age      | int(3)      | YES  |     | NULL    |       |
| money    | int(4)      | NO   |     | 10      |       |
| place    | varchar(10) | NO   |     | NULL    |       |
+----------+-------------+------+-----+---------+-------+
6 rows in set (0.00 sec)

5.复制一个表

结构和数据都有

新建一个和test2一样的test1表

mysql> create table test1 select * from test2;
Query OK, 0 rows affected (0.03 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> show tables;
+---------------+
| Tables_in_gao |
+---------------+
| t1            |
| t2            |
| t3            |
| t4            |
| t5            |
| t6            |
| test1         |
| test2         |
+---------------+
8 rows in set (0.00 sec)

只有表结构不需要数据

方法1:

create table 新表名 like 老表名

mysql> select * from test2;
+------+------+----------+------+-------+-------+
| id   | name | stu_name | age  | money | place |
+------+------+----------+------+-------+-------+
| NULL | gao  | NULL     |   20 |    10 | aa    |
+------+------+----------+------+-------+-------+
1 row in set (0.00 sec)

mysql> create table test3 like test1;
Query OK, 0 rows affected (0.03 sec)

mysql> select * from test3;
Empty set (0.00 sec)

方法二:

create table 新表名 select * from 旧表名 where 1=2;  ##条件为假 查不到任何记录

mysql> show tables;
+---------------+
| Tables_in_gao |
+---------------+
| t1            |
| t2            |
| t3            |
| t4            |
| t5            |
| t6            |
| test1         |
| test2         |
| test3         |
+---------------+
9 rows in set (0.00 sec)

mysql> create table test4 select * from test1 where 1=2;
Query OK, 0 rows affected (0.02 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> select * from test4;
Empty set (0.00 sec)

6.删除表

删除表test5

mysql> show tables;
+---------------+
| Tables_in_gao |
+---------------+
| t1            |
| t2            |
| t3            |
| t4            |
| t5            |
| t6            |
| test1         |
| test2         |
| test3         |
| test5         |
+---------------+
10 rows in set (0.00 sec)

mysql> drop table test5
    -> ;
Query OK, 0 rows affected (0.01 sec)

mysql> show tables;
+---------------+
| Tables_in_gao |
+---------------+
| t1            |
| t2            |
| t3            |
| t4            |
| t5            |
| t6            |
| test1         |
| test2         |
| test3         |
+---------------+
9 rows in set (0.00 sec)

原文地址:https://www.cnblogs.com/huizaia/p/9711461.html

时间: 2024-10-05 04:58:13

库操作和表操作的相关文章

mysql基本认识【关系型数据库和nosql、mysql操作流程和体系,库操作,表操作,数据的操作,字符集的操作,以及php作为client操作数据库】对连接本身没有疑问

1.关系型数据库永久性保存数据的仓库php的变量只是php脚本执行期间,临时性保存变量的空间[使用内存空间临时保存] 关系型数据库:利用二者的关系来描述实体的信息.[利用二维表字段名和字段值来进行描述][关系型数据库根本不是可以使用外键将两个表构建成关联的意思,而是实现描述实体的二维表的形式] nosql:not only sql[sql表示操作关系型数据的语言]所以nosql指的就是非关系型数据库[典型的是键值对型的数据(redis.memcache)][nosql可以视情况添加信息,不需要对

MySQL数据库:SQL语句基础、库操作、表操作、数据类型、约束条件、表之间的关系

数据库相关概念: 1. 数据库服务器:运行数据库管理软件的计算机 2. 数据库管理软件:MySQL.Oracle.db2.slqserver 3. 库:文件夹,用来组织文件/表 4. 表:文件(类似于excel),用来存放多行内容/多条记录 5. 记录:事物一系列典型的特征 6. 数据:描述事物特征的符号 MySQL数据库就是一个套接字软件,用来管理其他机器上的数据文件 MySQL介绍: MySQL是一个关系型数据库管理系统:就是一个基于socket编写的C/S架构胡软件 客户端软件 mysql

Hive命令行常用操作(数据库操作,表操作)

数据库操作 查看所有的数据库 hive> show databases ; 使用数据库default hive> use default; 查看数据库信息 hive > describe database default; OK db_name comment location owner_name owner_type parameters default Default Hive database hdfs://hadoop1:8020/user/hive/warehouse pub

模型层单表操作

模型层单表操作 单表操作 例: 1. 单表的查询 1. 单表查询所有用户:models.Book.objects.all() 得到的是 queryset对象(当成列表),列表里面,一个一个的对象[user1,user2] ? 2. render(request, 'booklist.html', {'book_list': ret}) ? 3. 模板里: {% for user in book_list %} #要循环的内容 {{book.name}} {% endfor%} 4. get请求携

Django学习手册 - ORM 数据表操作

queryset 数据类型介绍 QuerySet与惰性机制 所谓惰性机制:表名.objects.all()或者.filter()等都只是返回了一个QuerySet(查询结果集对象),它并不会马上执行sql,而是当调用QuerySet的时候才执行. QuerySet特点: <1>  可迭代的 <2>  可切片 <3>  惰性计算和缓存机制 例: info=models.table_name.objects.all()[0:5] #切片 info= models.table

Django-orm:单表查询、基于对象和双下划线的多表操作、集合查询、分组查询、F查询和Q查询

############################################## 单表操作 ############################################## 简单查: models.User.objects.filter(id=3) # queryset对象,相当于一个列表,放了一个或多个User对象 models.User.objects.filter(id=3).first() # User对象,相当于只去了queryset对象中的第一个 增: 第一种

myql基本库表操作

建立数据库 create database ff default character set utf8; create database if not exists ff default charcter set utf8; 删除数据库 drop database  ff; drop database if exists ff; 查询数据库 show create database db;//查询建库语句 show create database mysql;//查询建库语句 修改数据库字符集

MySQL之二:库、储存引擎、表操作

一.库操作 1.数据库命名规则: 可以由字母.数字.下划线.@.#.$ 区分大小写 唯一性 不能使用关键字如 create select 不能单独使用数字 最长128位 2.数据库相关操作 #创建数据库 create database 数据库名 charset utf8; #查看数据库 show databases; show create database db1; select database(); #查看当前所在数据库 #选择数据库 use 数据库名 #删除数据库 drop databa

mysql基础之对库表操作

原文:mysql基础之对库表操作 查看一下所有的库,怎么办? Mysql>Show databases; 选库语句: Use 库名 创建一个数据库: create database 数据库名 [charset 字符集] 删除一个数据库: drop database 数据库名; 把数据库改改名? Mysql中,表/列可以改名,database不能改名. phpMyAdmin似乎有这功能? 他是建新库,把所有表复制到新库,再删旧库完成的. 当选了库之后,我们面对的是表 查看库下面的所有表: show