【发布时间】:2019-07-02 22:30:04
【问题描述】:
我正在关注一个 PHP 工作簿,其中一个练习要求我使用以下 MySQL 代码创建一个包含列的表
CREATE TABLE messages (
message_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
parent_id INT UNSIGNED NOT NULL DEFAULT 0,
forum_id TINYINT UNSIGNED NOT NULL,
user_id MEDIUMINT UNSIGNED NOT NULL,
subject VARCHAR(100) NOT NULL,
body LONGTEXT NOT NULL,
date_entered DATETIME NOT NULL,
PRIMARY KEY (message_id),
INDEX (parent_id),
INDEX (forum_id),
INDEX (user_id),
INDEX (date_entered)
);
问题出在我工作的地方,他们使用 Microsoft SQL Server,因此语法不同。
我可以使用的等效 SQL Server 语法是什么
INDEX (parent_id),
INDEX (forum_id),
INDEX (user_id),
INDEX (date_entered)
【问题讨论】:
-
你有错误吗?显示确切的错误信息
-
是的,我得到
Incorrect syntax near 'INDEX'. If this is intended as a part of a table hint, A WITH keyword and parenthesis are now required. See SQL Server Books Online for proper syntax. -
当涉及到 RDBMS 供应商之间的不一致时,您遇到了冰山一角。
标签: mysql sql sql-server indexing syntax