简体   繁体   中英

Script create table on UNIX and sqldeveloper are different

what is the ddifference if in sqldeveloper command
select dbms_metadata.get_ddl('TABLE','table_name','owner') from dual;
gives me the result

    CREATE TABLE "OWNER"."TABLE_NAME"    
("HENCD" VARCHAR2(4),    
"HCACT" VARCHAR2(12),    
"HETID" VARCHAR2(30),    
"HERID" VARCHAR2(20),    
"HFNCD" VARCHAR2(1),    
"HPSIN" VARCHAR2(2)   
CONSTRAINT "PK_TRANQ_BPSBATCH" PRIMARY KEY         ("HETID", "HFNCD", "FIRM_CUST_IND")    
 USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS    
 STORAGE(INITIAL 1048576 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645    
 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1    
 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)    
 TABLESPACE "DAT01"  ENABLE    
  ) SEGMENT CREATION IMMEDIATE     
 PCTFREE 20 PCTUSED 80 INITRANS 1 MAXTRANS 255     
NOCOMPRESS LOGGING    
 STORAGE(INITIAL 302858240 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645    
 PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1    
  BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)    
  TABLESPACE "DAT01" "    

But in the actual script I see:

DROP TABLE table_name
/    


CREATE TABLEtable_name(    
hencd                          VARCHAR2(4),    
hcact                          VARCHAR2(12),    
hetid                          VARCHAR2(20),    
herid                          VARCHAR2(20),    
hfncd                          VARCHAR2(1),
hpsin                          VARCHAR2(1),    )
GRANT SELECT ON tran_queue_bps_batch TO public    
/    
GRANT ALL ON tran_queue_bps_batch TO dtebatch    
/    

-- Indexes for TRAN_QUEUE_BPS_BATCH    
CREATE INDEX indname1 ON table_name (intact_tag, hasdt)     
TABLESPACE idx01    
/    

Which one I have to use to drop and recreate a table with additional column?

"Which one I have to use to drop and recreate a table with additional column?"

If what you want to do is add a column then what you should is write a script which does

 alter table table_name add new_column number --- or whatever. 

No sense in dropping and recreating a table if you don't need to.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM