Is it possible to have definitions of columns in a table to create

I was wondering if it is possible to have calculated columns, such as those below in the statement CREATE TABLE in Oracle. And if so, how do write you?

* CREATE TABLE [Sales]. [SalesOrderHeader] (*
* [SalesOrderID] [int] IDENTITY (1,1) NOT for REPLICATION NOT NULL, *.
* [SalesOrderNumber] AS (isnull (do SO'+ CONVERT ([nvarchar] (23) [SalesOrderID], 0), no * ERROR *')), *.
* [Subtotal] [money] NOT NULL, *.
* [TaxAmt] [money] NOT NULL, *.
* [Transport] [money] NOT NULL, *.
* [TotalDue] AS (isnull (([SubTotal]+[TaxAmt]) + [Freight], (0))), *.
*)*

I would like to re - write the definition of table CREATE TABLE DTPartInv with partinv_flag AS a computed column when the value is X,
If partinv_instock < partinv_reorder and O
If partinv_instock > = partinv_reorder:

CREATE TABLE DTPartInv
(partinv_partnbr VARCHAR2 (10) NOT NULL,)
partinv_prodname VARCHAR2 (25).
partinv_desc VARCHAR2 (25).
partinv_manufact VARCHAR2 (25).
partinv_instock      INTEGER NOT NULL,
partinv_category VARCHAR2 (20).
partinv_purchdate DATE,
partinv_loc VARCHAR2 (15).
partinv_price NUMBER (6.2),
partinv_vendor VARCHAR2 (20).
partinv_reorder      INTEGER NOT NULL,
partinv_serial VARCHAR2 (20).
partinv_flag      VARCHAR2 (1).
CONSTRAINT DTPartInv_partinv_partnbr_pk
PRIMARY KEY (partinv_partnbr)
);
Advertisement

>
I was wondering if it is possible to have calculated columns, such as those below in the statement CREATE TABLE in Oracle. And if so, how do write you?
>

You did not mention your Oracle database version. Depending on your version, you can do. If you're on 11 GR 1 material or above, you can follow these steps:

CREATE TABLE DTPartInv
     ( partinv_partnbr VARCHAR2(10) NOT NULL,
     partinv_prodname VARCHAR2(25),
     partinv_desc VARCHAR2(25),
     partinv_manufact VARCHAR2(25),
     partinv_instock INTEGER NOT NULL,
     partinv_category VARCHAR2(20),
     partinv_purchdate DATE,
     partinv_loc VARCHAR2(15),
    partinv_price NUMBER(6,2),
    partinv_vendor VARCHAR2(20),
    partinv_reorder INTEGER NOT NULL,
    partinv_serial VARCHAR2(20),
    partinv_flag as (case when partinv_instock < partinv_reorder then 'X' else 'O' end),
    CONSTRAINT DTPartInv_partinv_partnbr_pk
    PRIMARY KEY (partinv_partnbr)
  ) ;

Table created.

-Test it now

-Box partinv_instock when <> _
SQL > insert into DTPartInv (partinv_partnbr, partinv_instock, partinv_reorder) values ('Test', 10, 20);

1 line of creation.

-Box when partinv_instock = partinv_reorder_
SQL > insert into DTPartInv (partinv_partnbr, partinv_instock, partinv_reorder) values ('Test2', 10, 10);

1 line of creation.

-Box when partinv_instock > partinv_reorder_

SQL > insert into DTPartInv (partinv_partnbr, partinv_instock, partinv_reorder) values ('Test3', 20, 10);

1 line of creation.

SQL> select partinv_partnbr, partinv_flag from DTPartInv;

PARTINV_PA P
---------- -
Test       X
Test2      O
Test3      O

3 rows selected.

Happy?

Therefore, always mention the version of database when you post specific requests as features differ from one version to the next.

Concerning

Tags: Database

Similar Questions

  • Is it possible to have a fixed column width and a URL link?

    I'm trying what a popup link on a column in a SQL report, but also have the report column a certain width. Can I have or not however at the same time.

    What I did was created a SQL report, published a column and he gave a URL redirect (page in application) as usual.

    Fixed column width, I used:
    <div style="width:250px; height:54px; overflow:hidden" title="#Comments#">#Comments#</div>
    The formatting of column / Expression HTML

    And for the URL of the popup, I used:
    onclick="window.open(this.href,'_blank','resizable=0,scrollbars=0,width=650,height=300,menubar=0,location=0');return false;" title="Comments"
    On the column link / link attributes

    Hello

    It is possible that there is an error in your code - shows your snapshot & 523. -the & and the. should not be there. If you have changed to that of & APP_ID., then you don't need the & or the. but, normally, you should leave as & APP_ID. as the value for this will change when you move from dev to test for prod and Apex will automatically replace this string with the number of correct application.

    Andy

  • Is it possible to select only one column of a table for the redaction?

    Hi, converted a Word doc with a table in PDF format.  You will need to write a single column of the table.

    Is it possible to select only one column for the redaction?  When we select and drag downwards, it selects the other columns in the following lines.

    With the help of Acrobat X Pro.  Any help is appreciated.

    Hold down the CTRL key and drag a selection.

  • How to check the index, on the number of columns in the table is created

    How to check on the number of columns in the table the index has been created. ??

    OR

    How check index, on the number of columns in the table that it is been created?

    890306 wrote:
    How to check on the number of columns in the table the index has been created. ??

    >

    OR

    How check index, on the number of columns in the table that it is been created?

    query USER_IND_COLUMNS

    SQL> desc user_ind_columns
     Name                            Null?    Type
     ----------------------------------------- -------- ----------------------------
     INDEX_NAME                             VARCHAR2(30)
     TABLE_NAME                             VARCHAR2(30)
     COLUMN_NAME                             VARCHAR2(4000)
     COLUMN_POSITION                        NUMBER
     COLUMN_LENGTH                             NUMBER
     CHAR_LENGTH                             NUMBER
     DESCEND                             VARCHAR2(4)
    

    Handle: 890306
    Status level: Beginner
    Join date: October 8, 2011
    Messages total: 13
    Total Questions: 5 (5 open)

    Why all the question still pending?

    Published by: sb92075 on December 3, 2011 17:21

  • I have the blob column in a table. I want to break up the value of the column in characters varchar2 (4000) (block).

    Example of

    create table test (id primary number, data key blob);

    I want to display like

    Select code, data of the test;

    ID data

    1 character 4000

    1 character 4000

    1 character 4000

    .

    .

    and soon.

    Please help me on this

    BLOB stores binary data. What is the point of converted them to a varchar2? If the LOB will store the character data, then the appropriate data type would be CLOB. Said that, assuming that you will use CLOB here is the answer to your question.

    drop table temp purge;

    create table temp

    (

    integer ID

    clob c_lob

    );

    declare

    CLOB var;

    Start

    DBMS_LOB.CREATETEMPORARY (var, true);

    because me in 1.32 loop

    DBMS_LOB. WriteAppend (var, 1000, rpad ('x', 1000, 'x'));

    end loop;

    insert into temp (id, c_lob) values (1, var);

    insert into temp (id, c_lob) values (2, var);

    commit;

    end;

    /

    Select id

    rno

    , length (dbms_lob.substr (c_lob, 4000, offset)) c_lob_var_len

    , dbms_lob.substr (c_lob, 4000, offset) c_lob_var

    de)

    Select id

    , ((level-1) * 4000) + 1 offset

    c_lob

    level NWR

    temp

    connect

    by level<=>

    and prior id = id

    and dbms_random.value (prior) is not null

    );

  • ViewCriteria comparing two columns of the table to create

    Anyone know how I can create a ViewCriteria where clause that compares the two columns of the same table?

    For example if I had two columns of integers (MINSAL and MAXSAL) and wanted to see if they are equal. Normally, I would do the following SQL below.

    SELECT * EMPL
    WHERE MINSAL = MAXSAL

    Try to link any of them to an expression of groovy.

    Timo

  • How to remove a virtual column in a table

    Is it possible to delete a virtual column in a table. Please give the full syntax for help do

    What do you mean delete?

    You can do DML on virtual columns because they do not exist. They are virtual...

    You can drop

    alter table table_name drop column column_name;
    
  • Is there a way to match all columns in a table?

    Oracle 11.1.0.7:

    Is it possible to say match all columns in A table with table B? For example:

    Table A
    --
    ID
    name

    Table B
    --
    ID
    name

    Is there a way to say matches all columns with a similar column in others in a select statement instead of making "where A.id = B.id and B.SID = b.name? I'm trying to write a script of comparison to check that replication is in effect doing the right thing.

    user628400 wrote:
    Is there a way to say use 'Less', but exclude the column 'y' and 'z' comparison?

    Not without explicitly listing the columns that you want to compare in the different SELECT lists, no.

    If it was something you wanted to do on a regular basis (looks like it's just a unique validation), you could potentially generate the statement LESS through dynamic SQL where you could easily exclude some columns. But it's more work that simply listing the column names in a static SQL statement, unless you plan to do on a regular basis.

    Justin

  • Is it possible to have a URL custom in Captivate premium?

    Is it possible to have a URL custom in Captivate premium?

    Hi John,.

    For now, first Captivate allows you to configure only a custom subdomain that can be done by logging into your account as an administrator and then click on 'Company info' on the left column.

    Click on the 'Change' link to the right of the subdomain, and you can choose something like yourcompanyname.captivateprime.com according to availability.

    If you have a domain/specific URL available to you that you want to use to access the first, then you can set a redirect to this URL to the URL of your premium account so that all learners access to this specific URL be re-directed to the URL of your default premium account.

    Kind regards

    Sharad

  • Is it possible to have an action that send an email?

    Hello

    is it possible to have an action email to a predefined address?

    Thank you.

    Hi nicolasf47082287,

    You can create a button "submit" in your PDF form & adds an action to send the PDF by email, see this KB document for help Acrobat help. Definition of action in PDF forms buttons.

    Kind regards
    Nicos

  • possible to have a display value and the return of LOV

    Hello

    With the help of obiee 11g, I have a variable prompt that takes column as value.
    I have the report that I use a diff column eual to this prompt value.
    I wanted to know if its possible at all to have a view and a return value
    i.e. in the lov, we show a value and when we choose we choose a different value that goes to the filter

    For example. If we have an APAC region in the table, and then in the show LOV in Asia-Pacific and it returns APAC, so that
    in the data filter gets filtered using ICCA.

    Thank you

    You can try something like this sql in the Prompt Variable:
    SELECT CASE WHEN Office.Region = "ACPA" THEN 'Asia-Pacific' WHERE Office.Region = END 'EMEA' THEN 'EUROPE' TO THE "subject domain name.

    And then in the report so you need to change the column fx filter
    CASE WHEN Office.Region = "ACPA" THEN 'Asia-Pacific' WHERE Office.Region = END 'EMEA' THEN 'EUROPE '.

    Note: This is very good for the case where you have less no.. of LOVs in the column.

    Hope it will be useful...

  • How to have more than 20 columns in a table in the form of adobe?

    I see that there is limitaion of not having more than 20 columns in my table in the form of adobe, is it possible that I can have more than 20 columns in a table in the form of adobe in landscape mode.

    Hello

    Which applies only to the Table Wizard. Once the table is placed on the page, you can add columns manually in the menu or by right-clicking a column.

    You can also use fields in a repeating subform (rather than the object of the table).

    Good luck

    Niall

  • Is it possible to have the window bookmark right?

    Is it possible to have the bookmark window, to the right of the screen instead of left? If Yes: how or where configure? I was not able to find.

    I've seen som questions where it seems he accidentally sits right - but no configuration option is mentioned.

    Are you referring to the bookmarks bar?

  • Just changed Safari on my imac. When you use find menu safari gave me the opportunity to "find in this page" which was an incredible aid during a search. Is it possible to have this feature using firefox?

    Just changed Safari on my imac. When you use the search menu in safari, I had the opportunity to "find in this page" which has been an incredible help while doing research and looking for specific words/phrases. Is it possible to have this feature using firefox?

    I think that Safari has the same keyboard shortcut in Firefox 'cmd + F' on a Mac or a 'Ctrl + F' on Windows.

    Look in the lower left corner to find. There are more likely to be next and previous differences in keyboard shortcuts, but continuing in the search bar at the bottom no matter what browser you use. It is an 'X' to reject the search bar. In Windows, the "Esc" key will reject the bar if you are in the search text entry box.

    Keyboard shortcuts:

    Please mark "resolved" a response that will better help others with a similar problem - hope it was her.

  • For any folder of bookmarks, is - it possible to have subfolders appear * superior * individual links?

    For any folder of bookmarks, is - it possible to have subfolders appear all * superior * the individual links (as they do in Internet Explorer), rather than mixed together in alphabetical order? (Or maybe an add-on that will allow me to do this?)

    The add-on SortPlaces can be useful to you, it gives greater control to sort the bookmarks and folders.

Maybe you are looking for

  • Cannot open firefox

    When I open firefox in normal mode and safe the crash reporter open an ask restart me firefox and whenever I click on restart firefox, I got another delay of the accident.Crash ID: bp-9e7de36c-3e17-42f2-9722-cb2892130717

  • my macbook pro is running yosemite with several kernel panics

    I have problems sending messages and providing a copy of the panic the kernel connects what to do? It is said contains invalid characters.

  • customer needs to source code

    Not sure if this is the right forum, but someone might suggest the best location for the answer if it's not? Briefly, client asked to buy the source code that is used to run my test platforms so they can change it if necessary. They have very limited

  • BSOD STOP NFP-LIST-CORRUPT

    I have a hp Pavilion media center a1340n desktop which has begun to have problems starting. Has decided to recover the system, contacted HP and purchased restore disc in 3 disks and 1 additional disk. installed the drive and started the recovery proc

  • BlackBerry Smartphones blackberry 8900 curve: call failure needed help

    Hello. I have a curve 8900 that I got off of ebay from a seller who got very good food back. However the when I got on the phone he has an orange logo on the back of the phone. the seller has unlocked the phone. but everytime I make a call from the p