INSERT语句的顺序不同 [英] INSERT statement in a different order
问题描述
什么SQL结构允许您以与它们在表中出现的顺序不同的顺序指定INSERT语句的列/值?
选择1
What SQL structure allows you to specify the columns/values for an INSERT statement in a different order than that in which they appear in the table?
Choice 1
The ORDER BY clause
选择2
Choice 2
The values list, as in "INSERT INTO employees VALUES (24, 'Smith', 'Barney')"
选择3
Choice 3
The column list, as in "INSERT INTO employees (emp_id, last_name, first_name)"
Choice 4
Choice 4
The ALTER TABLE statement
选择5
Choice 5
The SET statement
我自己没有得到问题。
那意味着 -
选择一个结构,它会让你为INSERT语句选择不同的顺序?
I am not getting the question itself.
Does that mean -
select a structure which will let you select the different order for INSERT statement ?
推荐答案
或许可以用另一种方式解释问题帮助...
想象一下,你创建了一个这样的表
Perhaps explaining the question another way might help ...
Imagine you have created a table like this
CREATE TABLE MyTable
(
COLUMN1 Varchar(15),
COLUMN2 Varchar(20),
COLUMN3 Varchar(3)
)
并且您想要将一些数据放入其中以便它最终结束...
and you want to put some data into it so that it ends up like this ...
COLUMN1 COLUMN2 COLUMN3
3 2 1
但是你想要通过e数据以您自己的顺序排列到您的插入查询 1,2,3
(不是3,2,1根据上图所示)
问题是问你将使用哪5个选项按顺序插入。
你对这个问题的解释并不遥远,但我会避免使用结构这个词 - 这是误导性的。问题的措辞会更好
But you want to pass the data to your insert query in your own order of
1, 2, 3
(NOT 3, 2, 1 as per the illustration above)
The question is asking you which of the 5 options would you use to do the insert in that order.
You were not far away with your interpretation of the question, but I would avoid the word "structure" - it is misleading. Better wording of the question would have been
选择一个sql 构造 可以让你选择INSERT语句的不同顺序
select a sql construct which will let you select the different order for INSERT statement
简单:
Simple:
INSERT INTO [Table] ([IntColumn], [NVarcharColumn]) VALUES (1, N'text')
可以通过以下方式完成:
could be done this way:
INSERT INTO [Table] ([NVarcharColumn], [IntColumn]) VALUES (N'text', 1)
这篇关于INSERT语句的顺序不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!