将列插入表的语法
是否可以向 MySQL 表中插入列?
我创建了一个表并将其命名为“my_table” - 我不明白,为什么 MySQL 不接受我的语法...
INSERT INTO "my_table"(
"item" char(1) NOT NULL DEFAULT '',
"price" int(10) NOT NULL DEFAULT '3000',
"level" int(10) NOT NULL DEFAULT '1000',
"super" char(1) NOT NULL DEFAULT '',
"play" char(1) NOT NULL DEFAULT ''
)
错误消息:
1064 - 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,了解在第 1 行 '"my_table"( "item" char(1) NOT NULL DEFAULT '', "price" i' 附近使用的正确语法
那么我的语法有什么问题吗?
Is it possible to insert columns into a MySQL table??
I've created a table and named it "my_table" - I do not understand, why MySQL does not eats my syntax...
INSERT INTO "my_table"(
"item" char(1) NOT NULL DEFAULT '',
"price" int(10) NOT NULL DEFAULT '3000',
"level" int(10) NOT NULL DEFAULT '1000',
"super" char(1) NOT NULL DEFAULT '',
"play" char(1) NOT NULL DEFAULT ''
)
Error message:
1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"my_table"( "item" char(1) NOT NULL DEFAULT '', "price" i' at line 1
So what's wrong with my syntax ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您尝试向已创建的表添加列,则必须使用 ALTER。
http://dev.mysql.com/doc/refman/5.1 /en/alter-table.html
http://www.techiecorner.com/560/mysql-how-to-add-column-to-existing-table/
If you're trying to add columns to an already created table you must use ALTER.
http://dev.mysql.com/doc/refman/5.1/en/alter-table.html
http://www.techiecorner.com/560/mysql-how-to-add-column-to-existing-table/
正如文档说得很清楚,
INSERT
用于插入数据行,而不是更改架构。请查看
ALTER
。表/字段名称用反引号分隔,而不是引号。
As the documentation says quite clearly,
INSERT
is for inserting rows of data, not altering the schema.Look at
ALTER
instead.And table/field names are delimited with backticks, not quotation marks.