MySQL的数据库中建库建表
指定字符集建库:
mysql> create database dkukoc DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
Query OK, 1 row affected (0.00 sec)
mysql> show create database dkukoc\G;
*************************** 1. row ***************************
Database: dkukoc
Create Database: CREATE DATABASE `dkukoc` /*!40100 DEFAULT CHARACTER SET utf8 */
1 row in set (0.00 sec)
ERROR:
No query specified
提示:建库的字符集是随着mysql数据库默认生成的,如果已经设置了utf8字符集,建库的时候就可以不加指定字符集参数了。
指定字符集建表:
mysql> use dkukoc;
Database changed
mysql> create table student(
-> id int(4) not null auto_increment,
-> name char(10) not null,
-> primary key(id),
-> key index_name(name)
-> );
Query OK, 0 rows affected (0.01 sec)
mysql> show create table student\G;
*************************** 1. row ***************************
Table: student
Create Table: CREATE TABLE `student` (
`id` int(4) NOT NULL AUTO_INCREMENT,
`name` char(10) NOT NULL,
PRIMARY KEY (`id`),
KEY `index_name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.00 sec)
ERROR:
No query specified