SQL 如何仅创建特定列并将其从 table A 导入到新的 table、table B

SQL how to create and import only specific columns from table A to a new table, table B

在Table中,我有很多字段,如referenceid、amount、timestamp、remarks、status、balancebefore、balanceafter、frmsisdn、tomsisdn、id等

我想基于 Table A(具有列名、数据类型等)创建一个新的 table、Table B,但我只需要 table A.

我尝试从 TableA select * 进入 TableB,其中 1 = 2 但它说 ORA-00905:缺少关键字。我正在使用 TOAD。

谢谢

在 Oracle 中,正确的语法是 create table asSELECT INTO 主要用于 SQL Server 和 Sybase。

create table tableb as
    select . . .
    from tableA;

如果您实际上不想插入任何行,则只包含 where 子句。

在 MySQL 中,语法与 Oracle 的相同(参见 here)。

请注意,新的 table 不包含原始 table 的任何约束(索引、键等)