Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8105927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:18:06+00:00 2026-06-06T00:18:06+00:00

Given a table like: CREATE TABLE MyTable ( MyColumn NUMBER NOT NULL ); I

  • 0

Given a table like:

CREATE TABLE "MyTable" 
(
  "MyColumn" NUMBER NOT NULL
);

I want to create a view like:

CREATE VIEW "MyView" AS
SELECT
    CAST("MyColumn" AS BINARY_DOUBLE) AS "MyColumn"
FROM "MyTable";

Only where the column “MyColumn” is “NOT NULL”.

In SQL Server this is pretty straight forward:

CREATE VIEW [MyView] AS
SELECT
    ISNULL(CAST([MyColumn] AS Float), 0.0) AS [MyColumn]
FROM [MyTable];

However the Oracle equivalent results in a “NULL” column:

CREATE VIEW "MyView" AS
SELECT
    NVL(CAST("MyColumn" AS BINARY_DOUBLE), 0.0) AS "MyColumn"
FROM "MyTable";

Is there anyway to force Oracle to mark the view’s column as “NOT NULL” in the metadata?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T00:18:07+00:00Added an answer on June 6, 2026 at 12:18 am

    You can’t add a not null or check constraint to a view; see this and on the same page ‘Restrictions on NOT NULL Constraints’ and ‘Restrictions on Check Constraints’. You can add a with check option (against a redundant where clause) to the view but that won’t be marked as not null in the data dictionary.

    The only way I can think to get this effect is, if you’re on 11g, to add the cast value as a virtual column on the table, and (if it’s still needed) create the view against that:

    ALTER TABLE "MyTable" ADD "MyBDColumn" AS
        (CAST("MyColumn" AS BINARY_DOUBLE)) NOT NULL;
    
    CREATE OR REPLACE VIEW "MyView" AS
    SELECT
        "MyBDColumn" AS "MyColumn"
    FROM "MyTable";
    
    desc "MyView"
    
     Name                                      Null?    Type
     ----------------------------------------- -------- ----------------------------
     MyColumn                                  NOT NULL BINARY_DOUBLE
    

    Since you said in a comment on dba.se that this is for mocking something up, you could use a normal column and a trigger to simulate the virtual column:

    CREATE TABLE "MyTable" 
    (
      "MyColumn" NUMBER NOT NULL,
      "MyBDColumn" BINARY_DOUBLE NOT NULL
    );
    
    CREATE TRIGGER "MyTrigger" before update or insert on "MyTable"
    FOR EACH ROW
    BEGIN
        :new."MyBDColumn" := :new."MyColumn";
    END;
    /
    
    CREATE VIEW "MyView" AS
    SELECT
        "MyBDColumn" AS "MyColumn"
    FROM "MyTable";
    
    INSERT INTO "MyTable" ("MyColumn") values (2);
    
    SELECT * FROM "MyView";
    
      MyColumn
    ----------
      2.0E+000
    

    And desc "MyView" still gives:

     Name                                      Null?    Type
     ----------------------------------------- -------- ----------------------------
     MyColumn                                  NOT NULL BINARY_DOUBLE
    

    As Leigh mentioned (also on dba.se), if you did want to insert/update the view you could use an instead of trigger, with the VC or fake version.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table defined like this: CREATE TABLE mytable (id INT NOT NULL
My video_episodes table is like: CREATE TABLE video_episodes ( id integer NOT NULL PRIMARY
Given a table of id, 'points' and coordinates, would like to create a view
Given a table holding edges in a directed graph like this: CREATE TABLE edges
I have a table that looks like this: Id (PK, int, not null) ReviewedBy
So given: CREATE TABLE stuff ( really_long_title int(10) NO NULL auto_increment, really_long_title_number_1 varchar(10) NO
Given a query like: SELECT table1.field1 FirstField, table2.field2 SecondField FROM table1 INNER JOIN table2
Let's say I have SELECT name FROM table which gives me something like foo
Problem Given the following two tables, I'd like to select all Ids for Posts
Given a table row, I want to get the HTML out of the span

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.