在MySQL中,可以使用CREATE DATABASE语句来创建数据库。以下是一些常用的创建数据库的SQL语句:
CREATE DATABASE database_name;
CREATE DATABASE database_name CHARACTER SET character_set_name COLLATE collation_name;
CREATE DATABASE database_name;
GRANT ALL PRIVILEGES ON database_name.* TO 'username'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
CREATE DATABASE database_name DEFAULT CHARACTER SET character_set_name DEFAULT COLLATE collation_name ENGINE=engine_name;
CREATE DATABASE database_name
[[DEFAULT] CHARACTER SET character_set_name]
[[DEFAULT] COLLATE collation_name]
[COMMENT 'string']
[ENCRYPTION [=] {'Y' | 'N'}]
[EVENT_RETENTION = number]
[PAGE_SIZE = number]
[AUTO_INCREMENT [=] number]
[MAX_ROWS [=] number]
[MIN_ROWS [=] number]
[AVG_ROW_LENGTH [=] number]
[DATA DIRECTORY [=] 'directory']
[INDEX DIRECTORY [=] 'directory']
[DELAY_KEY_WRITE [=] {'Y' | 'N'}]
[ROW_FORMAT [=] {DEFAULT | DYNAMIC | FIXED | COMPRESSED | REDUNDANT | COMPACT}]
[TABLESPACE [=] tablespace_name]
[STORAGE [=] {'DEFAULT' | 'DISK' | 'MEMORY'}]
[TABLESPACE_STORAGE [=] {'DEFAULT' | 'DISK' | 'MEMORY'}]
[CONNECTION [=] {'DEFAULT' | 'PERFORMANCE' | 'SCALABILITY' | 'REDUNDANCY' | 'PROXY'}]
[UNDO_TABLESPACE [=] tablespace_name];
请注意,以上答案仅供参考,具体的SQL语句和相关参数可能会根据不同的MySQL版本和环境有所变化。在实际应用中,请根据具体需求和文档进行相应的调整和使用。
领取专属 10元无门槛券
手把手带您无忧上云