同一个数据库的一个表的数据怎么导入到另一个表?
insert into tbTree2(Name,ParentID,OrderId) select Name,ParentID,OrderId from tbTree
如何把同一个表的一列数据复制到另一列去?
update users set users.users_name = users.name from users where users.id = users.id
*******************************************************************************************
insert
into
pd_city
(CITY_CNAME,CITY_ENAME,CITY_CODE,CITY_CODE_3,COUNTRY_CODE,PROVINCE_CODE,LINE_CODE,CR_CODE,CR_TIME,OP_CODE,OP_TIME,EDI_CSAV,EDI_MOL)
select
CITY_CNAME,CITY_ENAME,CITY_CODE,CITY_CODE_3,COUNTRY_CODE,PROVINCE_CODE,LINE_CODE,CR_CODE,CR_TIME,OP_CODE,OP_TIME,EDI_CSAV,EDI_MOL from pd_city1
http://www.javaeye.com/topic/129126
(CITY_CNAME,CITY_ENAME,CITY_CODE,CITY_CODE_3,COUNTRY_CODE,PROVINCE_CODE,LINE_CODE,CR_CODE,CR_TIME,OP_CODE,OP_TIME,EDI_CSAV,EDI_MOL)
select
CITY_CNAME,CITY_ENAME,CITY_CODE,CITY_CODE_3,COUNTRY_CODE,PROVINCE_CODE,LINE_CODE,CR_CODE,CR_TIME,OP_CODE,OP_TIME,EDI_CSAV,EDI_MOL from pd_city1
比如那个insert的语法树,你那个写法包含在了那个derived_table的情况里面。
代码
- [ WITH <common_table_expression> [ ,...n ] ]
- INSERT
- [ TOP ( expression ) [ PERCENT ] ]
- [ INTO]
- { <object> | rowset_function_limited
- [ WITH ( <Table_Hint_Limited> [ ...n ] ) ]
- }
- {
- [ ( column_list ) ]
- [ <OUTPUT Clause> ]
- { VALUES ( { DEFAULT | NULL | expression } [ ,...n ] )
- | derived_table
- | execute_statement
- }
- }
- | DEFAULT VALUES
- [; ]
- <object> ::=
- {
- [ server_name . database_name . schema_name .
- | database_name .[ schema_name ] .
- | schema_name .
- ]
- table_or_view_name
- }
[
WITH <common_table_expression> [ ,n
]
]
INSERT
[ TOP ( expression ) [ PERCENT ] ]
[ INTO ]
{ < object > | rowset_function_limited
[ WITH ( <Table_Hint_Limited> [ n ] ) ]
}
{
[ ( column_list ) ]
[ <OUTPUT Clause> ]
{ VALUES ( { DEFAULT | NULL | expression } [ ,n ] )
| derived_table
| execute_statement
}
}
| DEFAULT VALUES
[ ; ]
< object > :: =
{
[ server_name . database_name . schema_name .
| database_name .[ schema_name ] .
| schema_name .
]
table_or_view_name
}
INSERT
[ TOP ( expression ) [ PERCENT ] ]
[ INTO ]
{ < object > | rowset_function_limited
[ WITH ( <Table_Hint_Limited> [ n ] ) ]
}
{
[ ( column_list ) ]
[ <OUTPUT Clause> ]
{ VALUES ( { DEFAULT | NULL | expression } [ ,n ] )
| derived_table
| execute_statement
}
}
| DEFAULT VALUES
[ ; ]
< object > :: =
{
[ server_name . database_name . schema_name .
| database_name .[ schema_name ] .
| schema_name .
]
table_or_view_name
}