Skip to content

Instantly share code, notes, and snippets.

@twobiers
Created August 30, 2020 12:20
Show Gist options
  • Save twobiers/255aa6f35730acfff81731a0068e75ec to your computer and use it in GitHub Desktop.
Save twobiers/255aa6f35730acfff81731a0068e75ec to your computer and use it in GitHub Desktop.
SQL Oracle ORDBS
-- Typ für Maßeinheiten erstellen
CREATE OR REPLACE TYPE measurement_unit AS OBJECT (
name VARCHAR2(45),
short VARCHAR2(5))
NOT FINAL;
-- Subtyp für flüssige Maßeinheiten, Umrechnung in Liter
CREATE OR REPLACE TYPE fluid_measurement_unit UNDER measurement_unit(
conversion_factor_to_liter NUMBER(20,10)
)
FINAL;
-- Subtyp für feste Maßeinheiten, Umrechnung in Gramm
CREATE OR REPLACE TYPE solid_measurement_unit UNDER measurement_unit(
conversion_factor_to_grams NUMBER(20,10)
)
FINAL;
-- Tabelle für die Maßeinheiten erstellen. Zusätzlichen künstlichen Primärschlüssel für Fremdschlüsselzuweisung
CREATE TABLE measurement_units (
id NUMBER(10) NOT NULL,
measurement_unit measurement_unit,
PRIMARY KEY (id));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment