Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating Enumerator Field in Oracle using values from another table
    primarykey
    data
    text
    <p>Greetings Fellow SOFs,</p> <p>My application has a lot of tables. And each table has 0/n number of Enumerators. Everything was going nice and bubbly, then all of a sudden my client now wants to move his data to Oracle(They had some native db till then.) Now we have managed to create the SQL for the tables that we have but were clueless with the Enumerators.</p> <p>I made a sacrifice to the Lord Internet(which basically meant me not looking at FB for like 1-2 hours) and found out that for oracle we can use :</p> <pre><code>Column_Name Data_type(size)(Check In(&lt;Possible Values&gt;)). </code></pre> <p>Looking at this closely I found that it would be better if we create tables for enumerators and use those tables as a constraint while inserting values. Something like </p> <p>Table Enumerator has 2 fields ID and Enumerator Values</p> <p>Table My_Table has a Name column which will only accept values which are present in the Enumerator Table. </p> <p>Reasons : 1. Most of the Enumerators are repeated across different tables. 2. If the client were to update any enumerator table, we don't want them to go back and change all the other table as well.</p> <p>I am looking at other solutions as well. But , I would be grateful to thee wise men if thee could guide me on my journey.</p> <p>Found the Solution to the null Problem as well :D... And Now I cna insert either an empty string (or) any one of the values from the table:</p> <pre><code>GOT THE SOLUTION :D </code></pre> <p>Mixed them both (i.e) CHECK IN as well as Constraint :D</p> <pre><code>CREATE TABLE "MY_TABLE1" ("ID" number(11) not null, "STATUS" varchar2(12) Check(STATUS IN('')), &lt;&lt; -- Did the trick, FOREIGN KEY("STATUS") REFERENCES MY_ENUM3("VALUES"), primary key ("ID")); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload