mysql教程 創建數據庫教程與刪除數據庫的方法
創建表語法
CREATE DATABASE <database>;
很簡單吧,看一個簡單的實例
mysql>
mysql>
mysql> CREATE DATABASE myDatabase;
Query OK, 1 row affected (0.03 sec)mysql>
mysql> drop database myDatabase;
Query OK, 0 rows affected (0.01 sec)mysql>
Under Unix, database and table names are case sensitive.
Under Windows, this restriction does not apply
mysql>
實例二,創建一個數據庫並設置為當前數據庫
mysql>
mysql>
mysql> CREATE DATABASE myDatabase;
Query OK, 1 row affected (0.02 sec)mysql> USE myDatabase; -- Select it manually
Database changed
mysql> drop database myDatabase;
Query OK, 0 rows affected (0.00 sec)mysql>
mysql>
綜合上面的,我們利用創建數據,創建表,再刪除數據庫一起操作。
mysql> CREATE DATABASE myDatabase DEFAULT CHARACTER SET latin2 COLLATE latin2_czech_ci;
Query OK, 1 row affected (0.02 sec)mysql>
mysql>
mysql>
mysql> USE myDatabase;
Database changed
mysql>
mysql> CREATE TABLE myTable
-> (
-> c1 CHAR(10)
-> );
Query OK, 0 rows affected (0.03 sec)mysql>
mysql> drop table myTable;
Query OK, 0 rows affected (0.00 sec)mysql>
mysql> drop database myDatabase;
Query OK, 0 rows affected (0.00 sec)mysql>
mysql> use test;
Database changed