容易複製品、拷貝或者備份表在Oracle、PostgreSQL、DB2和SQLite與創造表作為SQL

在Oracle、PostgreSQL、DB2和SQLite數據庫系統,有叫的一個好的命令特點 創造表 哪些允許容易複製一張桌以數據從另或幾張其他桌。 SQL命令在原始表可能也用於`拷貝和確切地黏貼』桌或備份桌數據在執行數據操作詢問之前,萬一劇本有錯誤,并且備份日期可以用於恢復對原始的狀態。 創造表 意志創造從數據集或結果集合內容修造的一張新的桌a檢索的 精選 SQL詢問從在數據庫之內已經存在的桌。

當SQL聲明是,句法創造表:

創造表table_name [(column_name [,…] )]
如精選[*! (column_name [,…] )]從source_table_name

用將被創造新的桌的名字替換table_name。 列名是任意的,您能通過包括他們的名字指定多個專欄的地方在一張逗號被劃定的名單。 新的桌的結構根據精選的聲明返回的列名、類型和列數,與列數據一起。 如果您指定列名,注意應該有同一列數指定像由精選返回。

精選的聲明在結尾創造桌,當命令一定是合法的,并且有目標的數量被選擇匹配列數在任意專欄名單在之前作為條目。 它可以是從多張桌檢索數據的一個複雜精選的聲明。 如果任意專欄名單在括號之內指定,星號(*)可能不再用於精選的聲明。

例如,

創造表demo_backup
如精選*從演示;

在SQL之上聲明將創造名為demo_backup的一張確切的複製品備用桌與數據和結構(專欄)演示桌。

可能的錯誤,如果您指定任意專欄名單是:

錯誤: 創造TABLE/AS精選配錯了專欄計數

如果您遇到這個錯誤信息,這比精選的聲明回歸歸結於專欄任意名單括號內包含不同的行數。 仔細檢查,如果指定的列數是同樣以期望從精選的resultset的結果。

重要 : This is a machine translated page which is provided "as is" without warranty. Machine translation may be difficult to understand. Please refer to original English article whenever possible.

Share and contribute or get technical support and help at My Digital Life Forums.



One Response to “Easily Duplicate, Copy or Backup Tables in Oracle, PostgreSQL, DB2 and SQLite with Create Table As SQL”

  1. Suraj
    August 27th, 2008 22:01
    1

    Awesome dude!!…. helped me bigtime… simple and effective as it could be… Thanks

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe without commenting


Custom Search

New Articles

Incoming Search Terms for the Article

oracle copy table - oracle backup table - copy table oracle - backup table oracle - sql backup table - backup oracle table - sqlite copy table - backup table in oracle - table backup in oracle - COPY TABLE in oracle - oracle table backup - db2 copy table - copy oracle table - oracle table copy - oracle sql copy table - postgresql duplicate table - sql duplicate table - oracle copy table data - create backup table in oracle - copy table db2 - postgresql copy table - oracle backup a table - oracle duplicate table - all - How to backup table in oracle - BACKUP A TABLE IN ORACLE - backup tables in oracle - ORACLE SQL COPY - duplicate table oracle - postgres duplicate table - SQL ORACLE copy table - DB2 table copy - postgres copy table - oracle create backup table - oracle copy a table - copy table oracle sql - sql copy table - copy table sql oracle - oracle backup tables - oracle backup table data - oracle table backup command - copy table postgres - oracle copy statement - copy table sqlite - backup an oracle table - db2 backup table - how to backup an oracle table - postgres backup - backup table in sql - copying a table in oracle -