日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

mysql对数据库的操作_MySQL数据库对数据库的操作

發(fā)布時間:2023/12/10 数据库 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql对数据库的操作_MySQL数据库对数据库的操作 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1.創(chuàng)建數據庫mysqlgt; create database if not exists tongcheng; Query OK, 1 row affected (0.01 sec) mysqlgt; 2.查看創(chuàng)建數

1.創(chuàng)建數據庫

mysql> create database if not exists tongcheng;

Query OK, 1 row affected (0.01 sec)

mysql>

2.查看創(chuà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.連接數據庫

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創(chuàng)建數據庫

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 ~]#

本條技術文章來源于互聯(lián)網,如果無意侵犯您的權益請點擊此處反饋版權投訴

本文系統(tǒng)來源:php中文網

總結

以上是生活随笔為你收集整理的mysql对数据库的操作_MySQL数据库对数据库的操作的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。