容易复制品、拷贝或者备份表在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 - db2 copy table - oracle table backup - oracle table copy - postgresql duplicate table - copy oracle table - sql duplicate table - oracle sql copy table - oracle copy table data - copy table db2 - oracle backup a table - create backup table in oracle - all - How to backup table in oracle - BACKUP A TABLE IN ORACLE - postgresql copy table - backup tables in oracle - ORACLE SQL COPY - duplicate table oracle - oracle duplicate table - postgres duplicate table - SQL ORACLE copy table - DB2 table copy - oracle create backup 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 - oracle copy a table - copy table sqlite - backup an oracle table - db2 backup table - how to backup an oracle table - postgres backup - copying a table in oracle - db2 copy tables - oracle sql backup table -