當前位置:首頁 » 操作系統 » 復制資料庫表

復制資料庫表

發布時間: 2022-01-08 23:12:48

① 如何把一個資料庫的所有表復制到到另一個資料庫

如果另一個庫中沒有同名的表
select
*
into
b資料庫.dbo.a表
from
a資料庫.dbo.a表
where
條件
如果是追加到另一個表中
inert
into
b資料庫.dbo.a表
select
*
from
a資料庫.dbo.a表
where
條件
不同資料庫的格式:
[資料庫名.所有者名.表名]
insert
into
資料庫b.dbo.表2
select
*
from
資料庫a.dbo.表1
where
....

② 復制資料庫表

lj="data/ZWsys.mdb"
xjlj="data/"&request.form("ztm")&".mdb"
Conn="Provider=Microsoft.Jet.OLEDB.4.0; Data source="
Set fso= server.CreateObject("Scripting.FileSystemObject")
fso.CopyFile Server.Mappath(lj),server.mappath(xjlj)
Set fso = Nothing
set conn=nothing
你可以試試這樣寫,如果是access資料庫的話可以用file直接復制你那個模版資料庫,不過如果是sql資料庫就不行了,因為sql資料庫運行時不能被復制。我用access的時候也用file來做資料庫備份和恢復,超級方便。

③ 如何復製表SQL

1、既復製表結構也復製表內容的SQL語句:

CREATE TABLE tab_new AS SELECT * FROM tab_old;

2、只復製表結構不復製表內容的SQL語句:

CREATE TABLE tab_new AS SELECT * FROM tab_old WHERE 1=2;

3、不復製表結構,只復制內容的sql語句:

SELECT vale1, value2 into Table2 from Table1

(3)復制資料庫表擴展閱讀:

SQL中常用的語句:

1、說明:創建資料庫

CREATE DATABASE database-name

2、說明:刪除資料庫

drop database dbname

3、說明:創建新表

create table tabname(col1 type1 [not null] [primary key],col2 type2 [not null],..)

根據已有的表創建新表:

A:create table tab_new like tab_old (使用舊表創建新表)

B:create table tab_new as select col1,col2… from tab_old definition only

4、說明:刪除新表

drop table tabname

5、說明:增加一個列

Alter table tabname add column col type

6、說明:添加主鍵

Alter table tabname add primary key(col)

7、說明:刪除主鍵

Alter table tabname drop primary key(col)

8、說明:創建索引

create [unique] index idxname on tabname(col….)

9、刪除索引

drop index idxname

④ 如何將一個資料庫表數據復制到另一個資料庫

不同的資料庫語法不同(sql
server和oracle為例),且復制包括目標表已存在和目標表不存在的情況,分別回答:
sql
server中,如果目標表存在:
1
insert
into
目標表
select
*
from
原表;
sql
server中,,如果目標表不存在:
1
select
*
into
目標表
from
原表;
oracle中,如果目標表存在:
1
2
insert
into
目標表
select
*
from
原表;
commit;
oracle中,如果目標表不存在:
1
create
table
目標表
as
select
*
from
原表;

⑤ 如何將資料庫中一張表的全部內容復制到資料庫中另一張表中

1、首先,打開並連接Sql Server,在源資料庫Source_db(源資料庫名稱)上右鍵,然後依次點擊「編寫表腳本為」→「CREATE到」→「新查詢編輯器窗口」。

⑥ 如何將一個資料庫中的一個表復制到另一個資料庫中的表中

「將一個資料庫中的一個表復制到另一個資料庫中的表中」的過程如下。

⑦ 如何復制一個表到另一個資料庫中

SQL:復制資料庫某一個表到另一個資料庫中

SELECT * INTO 表1 FROM 表2 --復製表2如果只復制結構而不復制內容或只復制某一列只要加WHERE條件就好了
例子:SELECT * INTO [IMCDB].[dbo].[SysLog] FROM [AimManageDB].[dbo].[SysLog]

(將資料庫AimManageDB中的SysLog表復制到資料庫IMCDB中)

跨伺服器復製表

select * INTO [SMSDB].[dbo].[SysLog] FROM openrowset('sqloledb',『目標伺服器』;'賬號';'密碼',[SMSDB].[dbo].[SysLog])

(將資料庫目標伺服器中的SysLog表復制本地的資料庫SMSDB中)

eg:如果出現以下錯誤:

(SQL Server 阻止了對組件 'Ad Hoc Distributed Queries' 的 STATEMENT'OpenRowset/OpenDatasource' 的訪問,因為此組件已作為此伺服器安全配置的一部分而被關閉。
系統管理員可以通過使用 sp_configure 啟用 'Ad Hoc Distributed Queries'。有關啟用 'Ad Hoc Distributed Queries' 的詳細信息,請參閱 SQL Server 聯機叢書中的
"外圍應用配置器"。)

解決方法:

啟用Ad Hoc Distributed Queries: exec sp_configure 'show advanced options',1 reconfigure exec sp_configure 'Ad Hoc Distributed Queries',1 reconfigure

使用完成後,關閉Ad Hoc Distributed Queries:exec sp_configure 'Ad Hoc Distributed Queries',0 reconfigure exec sp_configure 'show advanced options',0 reconfigure

2012-8-26 其他導入方法

select * from table1 into table2 table2必須不存在

insert into table2 select * from table1 table2必須存在

⑧ SQL server 資料庫 如何把一張表復制到另一個資料庫表中

SQLserver資料庫如何把一張表復制到另一個資料庫表中的方法。

如下參考:

1.首先,在桌面上單擊「ManagementStudio」圖標。

⑨ 怎樣將sql資料庫表復制到另一個sql資料庫中

結構一樣的話
insert into 資料庫A.dbo.TableA
select * from 資料庫B.dbo.TableA

另外:
nsert into DDD(欄位1,欄位2,欄位3 .....)
(
select 欄位1,欄位2,欄位3 ..... from AAA,BBB,CCC
)
插入的欄位和查詢的欄位數量類型一致
由於你的誇庫查詢插入
所以在表名前加 庫名.用戶名
insert into B.用戶.DDD(欄位1,欄位2,欄位3 .....)
(
select 欄位1,欄位2,欄位3 ..... from A.用戶.AAA,A.用戶.BBB,A.用戶.CCC
)
如果是sqlserver資料庫,可以在查詢分析器左邊菜單看到表用戶名,
如果你是在A庫下操作,可以省去A庫表的庫名.用戶名,同理B庫表也一樣

熱點內容
裝緩存下載 發布:2024-09-20 05:42:36 瀏覽:72
gon引擎自動回收腳本 發布:2024-09-20 05:39:39 瀏覽:246
好醫生連鎖店密碼多少 發布:2024-09-20 05:09:38 瀏覽:15
魔獸腳本代理 發布:2024-09-20 05:09:35 瀏覽:98
python登陸網頁 發布:2024-09-20 05:08:39 瀏覽:757
安卓qq飛車如何轉蘋果 發布:2024-09-20 04:54:30 瀏覽:178
存儲過程中in什麼意思 發布:2024-09-20 04:24:20 瀏覽:315
php顯示數據 發布:2024-09-20 03:48:38 瀏覽:501
源碼安裝軟體 發布:2024-09-20 03:44:31 瀏覽:354
入門編程游戲的書 發布:2024-09-20 03:31:26 瀏覽:236