mysql对数据库的操作_MySQL数据库对数据库的操作
1.創(chuàng)建數(shù)據(jù)庫(kù)mysqlgt; create database if not exists tongcheng; Query OK, 1 row affected (0.01 sec) mysqlgt; 2.查看創(chuàng)建數(shù)
1.創(chuàng)建數(shù)據(jù)庫(kù)
mysql> create database if not exists tongcheng;
Query OK, 1 row affected (0.01 sec)
mysql>
2.查看創(chuàng)建數(shù)據(jù)庫(kù)時(shí)的選項(xiàng)
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.連接數(shù)據(jù)庫(kù)
mysql> use tongcheng;
Database changed
mysql>
4.查看當(dāng)前的數(shù)據(jù)庫(kù)
mysql> select database();
+------------+
| database() |
+------------+
| tongcheng |
+------------+
1 row in set (0.01 sec)
mysql>
5.顯示所有數(shù)據(jù)庫(kù)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
| tongcheng |
+--------------------+
4 rows in set (0.00 sec)
mysql>
6.修改數(shù)據(jù)庫(kù)的屬性
mysql> alter database tongcheng character set gbk;
Query OK, 1 row affected (0.00 sec)
mysql>
7.刪除數(shù)據(jù)庫(kù)
mysql> drop database if exists tongcheng;
Query OK, 0 rows affected (0.02 sec)
mysql>
8.用mysqladmin創(chuàng)建數(shù)據(jù)庫(kù)
123 [root@localhost ~]# mysqladmin create tongcheng -u root -p
Enter password:
[root@localhost ~]#
9.用mysqlshow查看數(shù)據(jù)庫(kù)
[root@localhost ~]# mysqlshow -u root -p tongcheng
Enter password:
Database: tongcheng
+--------+
| Tables |
+--------+
+--------+
[root@localhost ~]#
10.用mysqlshow查看數(shù)據(jù)庫(kù)有多少表
[root@localhost ~]# mysqlshow -u root -p tongcheng
Enter password:
Database: tongcheng
+--------+
| Tables |
+--------+
| t |
+--------+
[root@localhost ~]#
11.用mysqlshow查看數(shù)據(jù)庫(kù)中表的信息
[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查看數(shù)據(jù)庫(kù)中表的索引信息
[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 ~]#
本條技術(shù)文章來(lái)源于互聯(lián)網(wǎng),如果無(wú)意侵犯您的權(quán)益請(qǐng)點(diǎn)擊此處反饋版權(quán)投訴
本文系統(tǒng)來(lái)源:php中文網(wǎng)
總結(jié)
以上是生活随笔為你收集整理的mysql对数据库的操作_MySQL数据库对数据库的操作的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 某测试仪控制系统的设计方案--ARM+F
- 下一篇: mysql实用管理器添加外键_MySQL