使用最少的数据将数据库从一个数据库复制到另 [英] Copy database from one database to another with minimum data

查看:44
本文介绍了使用最少的数据将数据库从一个数据库复制到另的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个500 GB的数据库。我必须从原始数据库创建一个大小为10 GB的示例数据库。在我的示例数据库中,我需要来自原始数据库的每个表的1000条记录的样本,因为原始数据库具有十万条记录。原始数据库表有约束和索引我想在我的示例数据库表中相同。



如何创建示例数据库?

Im having a database with 500 GB. I have to create a sample database from my original database with the size of 10 GB. In my sample database i need sample of 1000 records from each table from the original database since original database having lakhs of records. Original database tables have constraints and Index i want the same in my sample database tables.

How to create a sample database?

推荐答案

create database your_db_name

从table_name中选择前100 *进入table_name //对所有表使用此行



//更好的选择是你创建一个应用程序并在for循环中执行这个查询
create database your_db_name
select top 100 * into table_name from table_name // use this line for all tables

//better option is that you create an application and inside for loop execute this query


这篇关于使用最少的数据将数据库从一个数据库复制到另的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆