mysql資料庫基礎知識--一分鐘讓你資料庫入門(sql基礎語法篇)

2020-10-02 01:00:10

顯示資料庫語法

語法:show databases;

mysql> show databases;
+----------------------+
| Database             |
+----------------------+
| information_schema   |
| jdbc_xiangyang_liao1 |
| my_jdbc              |
| myfirstdb            |
| mysql                |
| performance_schema   |
| sys                  |
+----------------------+
7 rows in set (0.02 sec)

新建資料庫語法

語法:create database 庫名;

mysql> create database new_cre;
Query OK, 1 row affected (0.01 sec)

mysql> show databases;
+----------------------+
| Database             |
+----------------------+
| information_schema   |
| jdbc_xiangyang_liao1 |
| my_jdbc              |
| myfirstdb            |
| mysql                |
| new_cre              |
| performance_schema   |
| sys                  |
+----------------------+
8 rows in set (0.00 sec)

使用資料庫語法

語法:use 庫名;

mysql> use my_jdbc;
Database changed

顯示錶語法

語法:show tables;

mysql> show tables;
+-------------------+
| Tables_in_my_jdbc |
+-------------------+
| my_jd             |
| my_jdbc           |
| student           |
| ww                |
| www               |
| wwwww             |
+-------------------+
6 rows in set (0.01 sec)

查詢表語法

語法:select * from 表名;

mysql> select * from my_jdbc;
+------+----+------+
| name | id | pass |
+------+----+------+
| w    |  1 |  111 |
+------+----+------+
1 row in set (0.01 sec)