最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

MySQL数据库对数据库的操作

来源:动视网 责编:小采 时间:2020-11-09 10:32:01
文档

MySQL数据库对数据库的操作

MySQL数据库对数据库的操作:1.创建数据库mysqlgt; create database if not exists tongcheng; Query OK, 1 row affected (0.01 sec) mysqlgt; 2.查看创建数 1.创建数据库mysql> create database if not exists tongcheng; Query
推荐度:
导读MySQL数据库对数据库的操作:1.创建数据库mysqlgt; create database if not exists tongcheng; Query OK, 1 row affected (0.01 sec) mysqlgt; 2.查看创建数 1.创建数据库mysql> create database if not exists tongcheng; Query


1.创建数据库mysqlgt; create database if not exists tongcheng; Query OK, 1 row affected (0.01 sec) mysqlgt; 2.查看创建数

1.创建数据库
mysql> create database if not exists tongcheng;
Query OK, 1 row affected (0.01 sec)
mysql>

2.查看创建数据库时的选项
mysql> show create database tongcheng;
+-----------+----------------------------------------------------------------------+
| Database | Create Database |
+-----------+----------------------------------------------------------------------+
| tongcheng | CREATE DATABASE `tongcheng` /*!40100 DEFAULT CHARACTER SET latin1 */ |
+-----------+----------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql>

3.连接数据库
mysql> use tongcheng;
Database changed
mysql>

4.查看当前的数据库
mysql> select database();
+------------+
| database() |
+------------+
| tongcheng |
+------------+
1 row in set (0.01 sec)
mysql>

5.显示所有数据库
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
| tongcheng |
+--------------------+
4 rows in set (0.00 sec)
mysql>

6.修改数据库的属性
mysql> alter database tongcheng character set gbk;
Query OK, 1 row affected (0.00 sec)
mysql>

7.删除数据库
mysql> drop database if exists tongcheng;
Query OK, 0 rows affected (0.02 sec)
mysql>

8.用mysqladmin创建数据库
123 [root@localhost ~]# mysqladmin create tongcheng -u root -p
Enter password:
[root@localhost ~]#

9.用mysqlshow查看数据库
[root@localhost ~]# mysqlshow -u root -p tongcheng
Enter password:
Database: tongcheng
+--------+
| Tables |
+--------+
+--------+
[root@localhost ~]#

10.用mysqlshow查看数据库有多少表
[root@localhost ~]# mysqlshow -u root -p tongcheng
Enter password:
Database: tongcheng
+--------+
| Tables |
+--------+
| t |
+--------+
[root@localhost ~]#

11.用mysqlshow查看数据库中表的信息
[root@localhost ~]# mysqlshow -u root -p tongcheng t
Enter password:
Database: tongcheng Table: t
+-------+---------+-----------+------+-----+---------+-------+---------------------------------+---------+
| Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment |
+-------+---------+-----------+------+-----+---------+-------+---------------------------------+---------+
| a | int(11) | | YES | | | | select,insert,update,references | |
+-------+---------+-----------+------+-----+---------+-------+---------------------------------+---------+
[root@localhost ~]#

12.用mysqlshow查看数据库中表的索引信息
[root@localhost ~]# mysqlshow -u root -p -k tongcheng t
Enter password:
Database: tongcheng Table: t
+-------+---------+-----------+------+-----+---------+-------+---------------------------------+---------+
| Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment |
+-------+---------+-----------+------+-----+---------+-------+---------------------------------+---------+
| a | int(11) | | YES | MUL | | | select,insert,update,references | |
+-------+---------+-----------+------+-----+---------+-------+---------------------------------+---------+
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
| t | 1 | in_tong | 1 | a | A | | | | YES | BTREE | |
+-------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+
[root@localhost ~]#

文档

MySQL数据库对数据库的操作

MySQL数据库对数据库的操作:1.创建数据库mysqlgt; create database if not exists tongcheng; Query OK, 1 row affected (0.01 sec) mysqlgt; 2.查看创建数 1.创建数据库mysql> create database if not exists tongcheng; Query
推荐度:
标签: 操作 数据 数据库
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top