mySQL

初识:

show databases; //显示数据库

create database XX;//创建数据库

drop XX;  //删除

use XX; //切换数据库 

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| itm                |
| mysql              |
| performance_schema |
| sakila             |
| sys                |
+--------------------+
6 rows in set (0.02 sec)

mysql> creat database itcast;
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 'creat database itcast' at line 1
mysql> creat database aaa;
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 'creat database aaa' at line 1
mysql> creat database aaaaa
    -> sss
    -> ;
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 'creat database aaaaa
sss' at line 1
mysql> creat database mydate;
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 'creat database mydate' at line 1
mysql> create database mydata01;
Query OK, 1 row affected (0.02 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| itm                |
| mydata01           |
| mysql              |
| performance_schema |
| sakila             |
| sys                |
+--------------------+
7 rows in set (0.01 sec)

mysql> create database mydata01;
ERROR 1007 (HY000): Can't create database 'mydata01'; database exists
mysql> create database if not exist mydata01;
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 'exist mydata01' at line 1
mysql> create database if not exists mydata01;
Query OK, 1 row affected, 1 warning (0.01 sec)


mysql>
mysql> create database mydata01 charset utf8mb4;
ERROR 1007 (HY000): Can't create database 'mydata01'; database exists
mysql>  create database mydata02 charset utf8mb4;
Query OK, 1 row affected (0.01 sec)

mysql> show
    -> show databases;
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 'show databases' at line 2
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| itm                |
| mydata01           |
| mydata02           |
| mysql              |
| performance_schema |
| sakila             |
| sys                |
+--------------------+
8 rows in set (0.00 sec)

mysql> dropdatabase mydata01;
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 'dropdatabase mydata01' at line 1
mysql> drop database mydatabase01;
ERROR 1008 (HY000): Can't drop database 'mydatabase01'; database doesn't exist
mysql> drop database mydata01 if exists mydata01;
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 'if exists mydata01' at line 1
mysql> use mydata02;
Database changed

mysql> select database();
+------------+
| database() |
+------------+
| mydata02   |
+------------+
1 row in set (0.00 sec)

mysql> select database;
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 '' at line 1
mysql> use mydata01;
Database changed
mysql>

  • 5
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值