zzzzy09

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

基本操作增删改查

 

mysql> show databases;    #查看databases   记住后面要加s
+--------------------+
| Database           |
+--------------------+
| information_schema |
| employees          |
| mysql              |
| performance_schema |
| sys                |
| test               |
| test_db_char       |
+--------------------+
7 rows in set (0.00 sec)

mysql> show database like 'te%';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'database like 'te%'' at line 1
mysql> show databases like 'te%';    #使用 like 关键字进行模糊匹配查询  '%te%' , 'te%' , '%te'
+----------------+
| Database (te%) |
+----------------+
| test           |
| test_db_char   |
+----------------+
2 rows in set (0.00 sec)


mysql> show create database test;   #查看已经创建的  database 的信息 ,不需要加s 
+----------+--------------------------------------------------------------------------------+
| Database | Create Database                                                                |
+----------+--------------------------------------------------------------------------------+
| test     | CREATE DATABASE `test` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_bin */ |
+----------+--------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> create database user_zy;      #create  关键字创建数据库
Query OK, 1 row affected (0.00 sec)

mysql> show create database user_zy;   #查看信息
+----------+--------------------------------------------------------------------+
| Database | Create Database                                                    |
+----------+--------------------------------------------------------------------+
| user_zy  | CREATE DATABASE `user_zy` /*!40100 DEFAULT CHARACTER SET latin1 */ |
+----------+--------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| employees          |
| mysql              |
| performance_schema |
| sys                |
| test               |
| test_db_char       |
| user_zy            |
+--------------------+
8 rows in set (0.00 sec)

mysql> alter database user_zy default character set utf8;   #alter 关键字修改数据库信息
Query OK, 1 row affected (0.00 sec)

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

mysql> drop database if exists user_zy;
Query OK, 0 rows affected (0.01 sec)

 mysql> use user_zy;   #use 关键字选择数据库
 Database changed
 mysql>




 

帮助:

mysql> help contents;    #查询帮助文档列表
You asked for help about help category: "Contents"
For more information, type 'help <item>', where <item> is one of the following
categories:
   Account Management
   Administration
   Compound Statements
   Contents
   Data Definition
   Data Manipulation
   Data Types
   Functions
   Geographic Features
   Help Metadata
   Language Structure
   Plugins
   Procedures
   Storage Engines
   Table Maintenance
   Transactions
   User-Defined Functions
   Utility

mysql> help 'Account Management';  #查询指定信息

You asked for help about help category: "Account Management"
For more information, type 'help <item>', where <item> is one of the following
topics:
   ALTER USER
   CREATE USER
   DROP USER
   GRANT
   RENAME USER
   REVOKE
   SET PASSWORD

mysql> 

 

posted on 2020-05-27 16:21  zzzzy09  阅读(136)  评论(0编辑  收藏  举报