简体   繁体   English

如何将数据和表结构从一个表复制到另一个表?

[英]How to copy data and structure of table from one table to another?

In my first database named 'sshopping' has two tables IndiaStates and IndiaCity. 在我的第一个名为“购物”的数据库中,有两个表IndiaStates和IndiaCity。 I want to copy these both table in new database 'jaijinendera' . 我想将这两个表都复制到新数据库'jaijinendera'中。

IndiaStates has columns StateID (Primary Key) and StateName IndiaStates的列为StateID(主键)和StateName

IndiaCity has columns CityID(Primary Key) , StateID (Foreign Key),CityName IndiaCity的列为CityID(主键),StateID(外键),CityName

I used the query something like this 我用这样的查询

   Insert int jaijinendera..IndiaStates select * from sshopping..IndiaStates
   Insert int jaijinendera..IndiaCity select * from sshopping..IndiaCity

this has copied the data but not the keys (structure). 这已经复制了数据,但没有复制键(结构)。 What query should i made to copy proper structure and data from sshopping to jaijinendera 我应该进行什么查询才能将适当的结构和数据从购物复制到jaijinendera

Try using the SQL Server Generate script. 尝试使用SQL Server生成脚本。

Right click on DB where you want to export table structure and data. 右键单击要导出表结构和数据的数据库。 Select Task and generate script. 选择任务并生成脚本。 follow the wizard. 按照向导。 Select the object or entire database in the select object you want to generate script. 在要生成脚本的选择对象中选择对象或整个数据库。 Click on the Advance to select schema only (for structure)/ data only for data and schema and data for both. 单击高级以仅选择模式(对于结构)/仅数据作为数据以及模式和数据。

generate the script to file or clipboard. 生成脚本文件或剪贴板。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用PL / SQL将数据从一个表复制到另一张具有不同结构的表 - How to copy data from one to table another table with different structure using PL/SQL 将数据从一个表复制到另一表 - Copy Data from one table to another table 如何将数据从一个表复制到另一表? - How do i copy data from one table to another table? 在SQL Server中将整个表结构从一个表复制到另一个表 - copy whole table structure from one table to another in sql server 使用查询将数据从一个db的表复制到另一个db的表中(两个表具有相同的结构) - Copy data from table of one db into table of another db using query (both tables have same structure) 如何将数据从一个表复制到另一个“EXCEPT”一个字段 - How to copy data from one table to another “EXCEPT” one field 如何在PHP和MySQL中将几条记录从一台服务器上的表复制到另一台服务器上具有相同结构的表? - How to copy few records from a table on one server to the table with same structure on another server in PHP and MySQL? 无法将数据从一个表复制到另一个表 - Not able to copy data from one table to another 将 SELECT 数据从一个表复制到另一个表 - Copy SELECT data from one table to another 将数据从一个表动态复制到另一个表 - Dynamically copy data from one table to another
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM