Easily Duplicate, Copy or Backup Tables in Oracle, PostgreSQL, DB2 and SQLite with Create Table As SQL Facilmente duplicar, copiar ou fazer backup Quadros em Oracle, PostgreSQL, e DB2 com SQLite Como Criar tabela SQL
In Oracle, PostgreSQL, DB2 and SQLite database system, there is a nice command feature called Create Table As which allows easy duplicating of a table with data from another or a few other tables. Na Oracle, PostgreSQL, e DB2 sistema de base de dados SQLite, existe um recurso chamado comando nice Como Criar tabela que permite um fácil duplicação de uma tabela com dados de outro ou alguns outros quadros. The SQL command can also be used to ‘copy and paste’ a table exactly or backup a table data before performing data manipulation query on the original table, just in case the script has error and the backup date can be used to restore to original state. Create Table As will creates a new table built from the content of dataset or result set retrieved by a Select SQL query from a table that already exists within the database. O comando SQL também podem ser usados para "copiar e colar" um quadro exatamente uma mesa ou backup dos dados antes de executar os dados manipulação consulta sobre a tabela original, apenas no caso de o erro e tem script de backup data pode ser usado para repor a situação original . Como Criar tabela cria uma nova tabela será construída a partir do conteúdo dos dados ou resultados extraídos por um conjunto Selecione consulta SQL a partir de uma tabela que já existe no banco de dados.
The syntax of Create Table As SQL statement is: A sintaxe do SQL Como Criar tabela é a seguinte:
CREATE TABLE table_name [ ( column_name [, ...] ) ] CREATE TABLE table_name [(column_name [, ...])]
AS select [ * ! AS selecionar [*! ( column_name [, ...] ) ] FROM source_table_name (Column_name [, ...])] FROM source_table_name
Replace table_name with the name of the new table that will be created. Substituir table_name com o nome da nova tabela que será criado. Column name is optional, where you can specify multiple columns by including their names in a comma-delimited list. Coluna nome é opcional, onde você pode especificar múltiplas colunas por incluindo os seus nomes na lista delimitado por uma vírgula. Else, the structure of the new table will be based on the column names, types and number of columns returned by the Select statement, together with the row data. Else, a estrutura do novo quadro basear-se-á os nomes de coluna, tipo e número de colunas retornados pelo SELECT, juntamente com a linha de dados. If you specify the column name, note that there should be the same number of columns specified as are returned by select. Se você especificar no nome da coluna, note que não deveria haver o mesmo número de colunas especificado como sejam devolvidos por seleccionar.
The select statement at the end of create table as command must be valid, and has the number of targets selected matching the number of columns in the optional column list preceding the AS clause. A escolha declaração no final da tabela como criar comando deve ser válido, e tem o número de alvos seleccionados igualar o número de colunas da lista opcional coluna que precede a cláusula AS. It can be a complex select statement that retrieve data from multiple tables. Pode-se selecionar um complexo declaração que recuperar dados de múltiplas tabelas. If optional column list is specified within parentheses, asterisk (*) can no longer be used in the select statement. Se facultativo coluna lista é especificado dentro de parênteses, asterisco (*) já não pode ser utilizado na escolha declaração.
For example, Por exemplo,
CREATE TABLE demo_backup CREATE TABLE demo_backup
AS SELECT * FROM demo; AS SELECT * FROM demo;
Above SQL statement will create a exact replica backup table named demo_backup with data and structure (columns) of demo table. Acima comando SQL criará uma réplica exata backup chamado demo_backup tabela com os dados e estrutura (colunas) do demo tabela.
Possible error if you specify the optional column list is: Possível erro se você especificar a coluna lista é opcional:
ERROR: CREATE TABLE/AS SELECT has mismatched column count ERRO: CREATE TABLE / AS SELECT tem adaptado coluna contar
If you encounter this error message, this is due to optional list of columns in parentheses contains a different number of rows than the select statement returns. Se você encontrar esta mensagem de erro, esta é devida a lista de colunas opcionais, entre parênteses e contém um número diferente de linhas do que a escolha declaração volta. Double check if the number of columns specified is the same with the results that are expected from the select resultset. Verifique se o número de colunas especificado é o mesmo com os resultados que são esperados a partir da escolha Resultset.
IMPORTANT : This is a machine translated page which is provided "as is" without warranty. IMPORTANTE: Esta é uma página traduzida máquina que é fornecida "como está" sem garantia. Machine translation may be difficult to understand. A tradução automática pode ser difícil de compreender. Please refer to Por favor, consulte a original English article Inglês original article whenever possible. sempre que possível.
Share and contribute or get technical support and help at Compartilhe e contribuir ou obter suporte técnico e ajudar a My Digital Life Forums Minha vida digital Fóruns .
Related Articles Artigos relacionados
- ORA-02449 Oracle Drop Table Error ORA-02449 Oracle gota tabela erro
- Create New Table by Selecting Data from Other Tables with CREATE TABLE AS Criar uma nova tabela, selecionando dados de outras tabelas com criar tabela como
- Oracle ORA-14074 Create or Add New Partition Fails Error Oracle ORA-14074 criar ou adicionar novas partições falhar erro
- ORA-00942 Table or View Does Not Exist Oracle Error ORA-00942 Ver tabela ou não existe erro Oracle
- Check Oracle Version Check Oracle versão
- Oracle ORA-01658 Unable to Create INITIAL Extent for Segment in Tablespace Error Oracle ORA-01658 Não foi possível criar INICIAL Extensão para o segmento no tablespace Erro
- ORA-01502 Oracle Index in Unusable State ORA-01502 Oracle Índice inutilizáveis no Estado
- Change Oracle Database User Password Mudar banco de dados Oracle usuário Senha
- Insert Text Literal and Concatenation in Oracle SQL Inserir texto literal e concatenação no Oracle SQL
- How to Backup and Restore (Export and Import) MySQL Databases Tutorial Como a Backup e Restauração (de Importação e Exportação) Bancos de dados MySQL Tutorial

































August 27th, 2008 22:01 27 de agosto de 2008 22:01
Awesome dude!!…. Awesome dude!…. helped me bigtime… simple and effective as it could be… Thanks me ajudou bigtime… simples e eficaz como poderia ser… Graças