1. Home
  2. Docs
  3. MySQL
  4. 定义语句

定义语句

CREATE TABLE

DROP TABLE IF EXISTS `words`;
CREATE TABLE `words` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `word` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

ALTER TABLE

新增字段

ALTER TABLE words ADD COLUMN cc_word int unsigned not null default 0 AFTER word;

新增索引

ALTER TABLE `words2` ADD INDEX idx_word ( `word` )
ALTER TABLE `words` ADD INDEX idx_word ( `cc_word` )

官方资料

官方文档-sql-data-definition-statements

Was this article helpful to you? Yes No

How can we help?