`show create table` equivalent in oracle sql

后端 未结 6 721
无人及你
无人及你 2020-12-05 07:17

In MySql you can see the table definition (columns with their data types etc) with show create table table_name.

Is there a similar functionality for o

6条回答
  •  被撕碎了的回忆
    2020-12-05 07:42

    DDL is working for me and more simple all you need is to write DDL (SCHEMA_OWNER).(TABLE_NAME) ...for example ddl HR.LOCATIONS;....HR is the schema and LOCATION is table name ...make sure you write both the SCHEMA name and table NAME in capital here the output will be

    CREATE TABLE "HR"."LOCATIONS" 
    (   "LOCATION_ID" NUMBER(4,0), 
    "STREET_ADDRESS" VARCHAR2(40), 
    "POSTAL_CODE" VARCHAR2(12), 
    "CITY" VARCHAR2(30) CONSTRAINT "LOC_CITY_NN" NOT NULL ENABLE, 
    "STATE_PROVINCE" VARCHAR2(25), 
    "COUNTRY_ID" CHAR(2), 
     CONSTRAINT "LOC_ID_PK" PRIMARY KEY ("LOCATION_ID")
     USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 NOLOGGING COMPUTE 
    STATISTICS 
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT 
    FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
    TABLESPACE "EXAMPLE"  ENABLE, 
     CONSTRAINT "LOC_C_ID_FK" FOREIGN KEY ("COUNTRY_ID")
      REFERENCES "HR"."COUNTRIES" ("COUNTRY_ID") ENABLE
    ) SEGMENT CREATION IMMEDIATE 
    PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS NOLOGGING
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT 
    FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
    TABLESPACE "EXAMPLE" ;
    COMMENT ON COLUMN "HR"."LOCATIONS"."LOCATION_ID" IS 'Primary key of 
    locations table';
    COMMENT ON COLUMN "HR"."LOCATIONS"."STREET_ADDRESS" IS 'Street address 
    of an office, warehouse, or production site of a company.
    Contains building number and street name';
    COMMENT ON COLUMN "HR"."LOCATIONS"."POSTAL_CODE" IS 'Postal code of 
    the 
    location of an office, warehouse, or production site
    of a company. ';
    COMMENT ON COLUMN "HR"."LOCATIONS"."CITY" IS 'A not null column that 
    shows city where an office, warehouse, or
    production site of a company is located. ';
    COMMENT ON COLUMN "HR"."LOCATIONS"."STATE_PROVINCE" IS 'State or 
    Province where an office, warehouse, or production site of a
    company is located.';
    COMMENT ON COLUMN "HR"."LOCATIONS"."COUNTRY_ID" IS 'Country where an 
    office, warehouse, or production site of a company is
    located. Foreign key to country_id column of the countries table.';
    COMMENT ON TABLE "HR"."LOCATIONS"  IS 'Locations table that contains 
    specific address of a specific office,
    warehouse, and/or production site of a company. Does not store 
    addresses /
    locations of customers. Contains 23 rows; references with the
    departments and countries tables. ';
    CREATE INDEX "HR"."LOC_CITY_IX" ON "HR"."LOCATIONS" ("CITY") 
    PCTFREE 10 INITRANS 2 MAXTRANS 255 NOLOGGING COMPUTE STATISTICS 
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT 
    FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
    TABLESPACE "EXAMPLE" ;
    CREATE INDEX "HR"."LOC_COUNTRY_IX" ON "HR"."LOCATIONS" ("COUNTRY_ID") 
    PCTFREE 10 INITRANS 2 MAXTRANS 255 NOLOGGING COMPUTE STATISTICS 
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT 
    FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
    TABLESPACE "EXAMPLE" ;
    CREATE INDEX "HR"."LOC_STATE_PROVINCE_IX" ON "HR"."LOCATIONS" 
    ("STATE_PROVINCE") 
    PCTFREE 10 INITRANS 2 MAXTRANS 255 NOLOGGING COMPUTE STATISTICS 
    STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
    PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT 
    FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
    TABLESPACE "EXAMPLE" ;
    

提交回复
热议问题