Can I create constraints "Primary key - Foreign key" on materialized views?

Hello!
Can I create constraints "Primary key - Foreign key" on materialized views like on tables?
My purpose - is to make DB schema "COPY" with set of materialized views or tables, which take data from time to time from other tables situated.into another schema "ORIGINAL".
Also - I want to use reporting tool, like Crystal Reports, to make nice reports from schema "COPY". To make nice reports, I need primary-foreign relationships between materialized views or tables in schema "COPY".
Is it possible to use materialized views?
Or I should use only tables to get such result?
Thank you in advance.
Edited by: kogotok1 on Dec 3, 2010 5:01 PM

What happens when you try it? Or search the manuals.
http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/statements_6002.htm#i2105365
http://download.oracle.com/docs/cd/E11882_01/server.112/e10706/repmview.htm#REPLN360

Similar Messages

  • Why create a primary key on a VIEW?

    One of our developers found that you can establish a primary key on a VIEW. What are the circumstances which would warrant something like that?
    --=Chuck

    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:636499119911
    Tom,
    I am a bit confused about Constraints on Views. As per the documentation, they are not enforced. So
    what is the use for constraints on views ?
    As per "SQL Reference" documentation :
    <QUOTE>
    View constraints (at the view and at the column or attribute level) are declarative only. That is,
    Oracle does not enforce them. However, operations on views are subject to the integrity constraints
    defined on the underlying base tables, so you can enforce constraints on views through constraints
    on base tables.
    </QUOTE>
    Thanks for your time.
    Followup February 5, 2002 - 11am Central time zone:
    They are used for complex query rewrites with materialized views and such. It is more "meta data"
    -- it gives the optimizer more information, allows for a broader range of query rewriting to take
    place.
    "

  • Having a problem with creating/using a primary key on a view

    I have a problem with a primary key on a view
    I created the view and primary key as follows:
    CREATE OR REPLACE FORCE VIEW "MDD"."ROCK_LU" ("DESCRIPTION",
         UNIQUE ("DESCRIPTION") RELY DISABLE,
         CONSTRAINT "ROCK_LU_PK" PRIMARY KEY ("DESCRIPTION") RELY DISABLE) AS
    SELECT DESCRIPTION
    FROM MRMC_LU
    WHERE ROCK = 'T';
    The view with the primary key appears to have been created as there were no error messages. (The above was from the sql tab in sql developer.)
    When I try to create the foreign key on my mdd_hr table - I get an error
    /* hr_name - foreign key */
    ALTER TABLE mdd_hr add CONSTRAINT hr_name_fk FOREIGN KEY (hr_name) REFERENCES rock_lu(description);
    Error report:
    SQL Error: ORA-02270: no matching unique or primary key for this column-list.
    When I lookup the index in sql developer, rock_lu_pk is not there.
    All my other foreign keys work - but I don't understand what I am doing wrong with this one. Please help.
    glenn
    Background - as to why I want to use a view as a lookup table.
    The MRMC_LU table that the view is created from is structured like:
    DESCRIPTION - MINERAL - ROCK - MODIFIER - COMMODITY
    ANHYDRITE - T - T - T
    APLITE - T - - T
    GRAPHITE - T - - - T
    GREYWACKE - - T
    DESCRIPTION is a list of all names of minerals, rocks, modifiers and commodities. T is entered in each valid field. Often a description name is used for both a mineral and a rock or a mineral and a commodity or any other combination. Because this database is just starting up, it was more efficient to create one table that could be updated (and thereby automatically update the MINERAL_LU, ROCK_LU, MODIFIER_LY, COMMODITY_LU views) rather than create and maintain four separate but similar tables. A primary key cannot be generated for the MRMC_LU table as there are nulls in each column
    except DESCRIPTION.
    Perhaps there is a smarter way to do this?

    http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_85a.htm#2065512
    You can specify constraints on views and object views. You define the constraint at the view level using the out_of_line_constraint clause. You define the constraint as part of column or attribute specification using the inline_constraint clause after the appropriate alias.
    Oracle does not enforce view constraints. However, operations on views are subject to the integrity constraints defined on the underlying base tables. This means that you can enforce constraints on views through constraints on base tables.
    Restrictions on View Constraints
    View constraints are a subset of table constraints and are subject to the following restrictions:
    You can specify only unique, primary key, and foreign key constraints on views. However, you can define the view using the WITH CHECK OPTION clause, which is equivalent to specifying a check constraint for the view.
    Because view constraints are not enforced directly, you cannot specify INITIALLY DEFERRED or DEFERRABLE.
    View constraints are supported only in DISABLE NOVALIDATE mode. You must specify the keywords DISABLE NOVALIDATE when you declare the view constraint, and you cannot specify any other mode.
    You cannot specify the using_index_clause, the exceptions_clause clause, or the ON DELETE clause of the references_clause.
    You cannot define view constraints on attributes of an object column.
    Rgds.

  • Can I have a primary key as a non-unique column

    Hi all,
    I have a table with 35 columns and only one column in a not null column. But this column data is not unique. I want to create a primary key with non-unique index, can I don it, if it is not possible is there any other way to it. Please help me with this.
    Thanks for your help.vinaykotha

    1) Do the 'Unique Column combination' check first, using this example. (Pl. Change the column name and number of columns you consider as candidate key.) The SQL as follows:-
    ;WITH CTE (ProductKey, CustomerKey, SalesTerritoryKey, DupRec)
     AS
      (SELECT ProductKey, CustomerKey, SalesTerritoryKey, ROW_NUMBER() OVER
         (PARTITION BY ProductKey, CustomerKey, SalesTerritoryKey
          ORDER BY ProductKey, CustomerKey, SalesTerritoryKey) AS DupRec
       FROM dbo.FactSales 
    SELECT *
    FROM CTE
    WHERE DupRec > 1
    2) if CTE Table returns no records, you are good to create a Composite CLUSTERED PRIMARY KEY, like:
    ALTER TABLE dbo.FactSales
    ADD CONSTRAINT PK_ProductKey_CustomerKey_SalesTerritoryKey 
    PRIMARY KEY CLUSTERED (ProductKey, CustomerKey, SalesTerritoryKey);
    If no error..bingo! if NOT, Don't worry, create a Composite Index like this:-
    3)
    CREATE NONCLUSTERED INDEX [IX_ProductKey_CustomerKey_SalesTerritoryKey] 
    ON dbo.FactSales(ProductKey, CustomerKey, SalesTerritoryKey);
    This will work still efficiently. Usually all transaction table are like that like Daily_Order table, Ship_Details table etc.
    -NC

  • Creating a primary key with the parallel option and the tablespace option

    I know I can create a unique index with these options and then make the primary key with the "using index" clause. anyway to do this and skip the create unique index and just create the primary key ?

    SQL> ALTER TABLE t
      2  ADD CONSTRAINT pk_t
      3  PRIMARY KEY (testcol)
      4  USING INDEX
      5  TABLESPACE example
      6  PARALLEL (DEGREE 2);
    PARALLEL (DEGREE 2)
    ERROR at line 6:
    ORA-03001: unimplemented featureYou can name the tablespace but you must do an alter index thereafter.

  • Is it possible to create many primary key for a table?

    hello sir/mam.
    i am selva, i am new to abap,
    is it possible to create many primary key for a table?
    please guide me.

    Hi Selva,
    Many Primary Keys = Composite Key.
    i.e some set of columns will enable you to identify a unique row from a set of rows in the table.
    This can be achieved by checking the primary key check box in se11.
    Hope it helps.
    Regards,
    Maheswaran.B
    Message was edited by: Maheswaran B

  • How can I create a short-key of an iconic button in Developer-6i

    Sir,
    How can I create a short-key of an iconic button in Developer-6i. Which works when I press the short-key the code execute which attach with button directly not just move the selection to this button and then need enter or click to execute the button.
    I am using oracle-9i and Developer-6i
    Thanks & Regards

    Hello,
    In the BUTTON PROPERTY set the property Access Key to any of your keyboard letter let say S.
    Then for that button you can use Alt+S. It will fire the trigger WHEN-BUTTON-PRESSED or it will work same as you are pressing button by enter or mouse.
    -Ammad

  • Can we create a shortcut key like ctr1+1 to cal a new form from the existin

    can we create a shortcut key like ctr1+1 to cal a new form from the existing form,i created using alt key by alloting a letter in access key of a button so it worked with alt button(alt+1) ,but i want a shortcut key which works with control button, i mean the shortcut key must be like ctrl+1 or ctrl+anyletter. On pressing ctrl+1 BUTTON or CTRL+ANY LETTER A NEW FORM must be called from the existing form.so please guide me how this can be achieved..
    i AM USING FORMS 5i

    EdStevens Wrote:
    And what is wrong with using a remote connection?
    Ideally I would like to implement it in an API tool that would create Oracle Databases for an API with specific prescriptions once give DBName and Password .
    Thus I think for an API tool to create remote shell connection maybe is an anti-pattern from Software Architecture
    e.g. I already red from Microsoft Doc that PSEXEC is sometime blocked from antiviruses
    But it was just a question, I may not do it, as informed, that companies having Oracle DB, usually have an Oracle DBA, and an Oracle DBA some times may not let anyone touch the Databases on the Server. Also Oracle DB Server might be on different Operating Systems while the API tool will always be Windows
    The method you use will necessarily be somewhat dependent on the OS of the server.  If Windows, what's wrong with using Windows Remote Desktop?  If *nix, as explained in your several other threads swirling around this question, use a putty session to connect ... then, if needed for a GUI utility like dbca, runInstaller, etc, just set up an x-server on your local machine and enable x-11 port forwarding in your putty session.
    You really are trying to make all of this much more difficult than it need be.
    Hmm... so in Windows a remote seems the only solution, except the one RichardHarisson proposed if you already have a Database set up. For Unix I can promote the port forwarding method you recomended. Thank you.
    Sorry I just finished my University and make my 1st internship on the Oracle DB Layer of Applications in Western Europe.
    P.S.
    There is no such a need but I would find it a personal good exercise in understanind these connections-administration issues under different OS to try create an API tool that creates DB on other PC of different OS once you chosen the OS of the Server.
    + I promess not to follow it with a flood of threads agains : P I already became better in finding what I need through docs, lol

  • Primary Key for Programmatic View

    Hi,
    I am using Jdev R2 for ADF. When I create a programmatic VO, Is it necessary to have a primary key for Programmatic VO, if yes, what can be the effective primary key?
    - Vinoth

    Hi Vino,
    Primary keys are used to loop through the collection on tables, list of values and to access rows on a view object.
    Juan Camilo

  • Primary Key for a view?

    Hi everybody,
    I am wondering if there is such thing as primary key for a view? Assuming, that my view is based on a single table and it's just a subset of columns (some of them renamed) including PK of the table it's based on.
    The reason for my question is this - we're using Reverse POCO generator which automatically generates C# Model class and Configuration file for our tables and views. For the view is lists all the columns as a key and therefore I obviously can not use normal
    way of updating that view. I posted that as an issue here https://efreversepoco.codeplex.com/workitem/115 but I am thinking there is no such thing as the "primary key" for a view.
    The query used to generate the classes is extremely complex already but may be it can be modified to get the PK ?
    SELECT [Extent1].[SchemaName],
    [Extent1].[Name] AS TableName,
    [Extent1].[TABLE_TYPE] AS TableType,
    [UnionAll1].[Ordinal],
    [UnionAll1].[Name] AS ColumnName,
    [UnionAll1].[IsNullable],
    [UnionAll1].[TypeName],
    ISNULL([UnionAll1].[MaxLength],0) AS MaxLength,
    ISNULL([UnionAll1].[Precision], 0) AS Precision,
    ISNULL([UnionAll1].[Default], '') AS [Default],
    ISNULL([UnionAll1].[DateTimePrecision], '') AS [DateTimePrecision],
    ISNULL([UnionAll1].[Scale], 0) AS Scale,
    [UnionAll1].[IsIdentity],
    [UnionAll1].[IsStoreGenerated],
    CASE WHEN ([Project5].[C2] IS NULL) THEN CAST(0 AS BIT)
    ELSE [Project5].[C2]
    END AS PrimaryKey
    FROM (
    SELECT QUOTENAME(TABLE_SCHEMA) + QUOTENAME(TABLE_NAME) [Id],
    TABLE_SCHEMA [SchemaName],
    TABLE_NAME [Name],
    TABLE_TYPE
    FROM INFORMATION_SCHEMA.TABLES
    WHERE TABLE_TYPE IN ('BASE TABLE', 'VIEW')
    ) AS [Extent1]
    INNER JOIN (
    SELECT [Extent2].[Id] AS [Id],
    [Extent2].[Name] AS [Name],
    [Extent2].[Ordinal] AS [Ordinal],
    [Extent2].[IsNullable] AS [IsNullable],
    [Extent2].[TypeName] AS [TypeName],
    [Extent2].[MaxLength] AS [MaxLength],
    [Extent2].[Precision] AS [Precision],
    [Extent2].[Default],
    [Extent2].[DateTimePrecision] AS [DateTimePrecision],
    [Extent2].[Scale] AS [Scale],
    [Extent2].[IsIdentity] AS [IsIdentity],
    [Extent2].[IsStoreGenerated] AS [IsStoreGenerated],
    0 AS [C1],
    [Extent2].[ParentId] AS [ParentId]
    FROM (
    SELECT QUOTENAME(c.TABLE_SCHEMA) + QUOTENAME(c.TABLE_NAME) + QUOTENAME(c.COLUMN_NAME) [Id],
    QUOTENAME(c.TABLE_SCHEMA) + QUOTENAME(c.TABLE_NAME) [ParentId],
    c.COLUMN_NAME [Name],
    c.ORDINAL_POSITION [Ordinal],
    CAST(CASE c.IS_NULLABLE
    WHEN 'YES' THEN 1
    WHEN 'NO' THEN 0
    ELSE 0
    END AS BIT) [IsNullable],
    CASE WHEN c.DATA_TYPE IN ('varchar', 'nvarchar', 'varbinary')
    AND c.CHARACTER_MAXIMUM_LENGTH = -1 THEN c.DATA_TYPE + '(max)'
    ELSE c.DATA_TYPE
    END AS [TypeName],
    c.CHARACTER_MAXIMUM_LENGTH [MaxLength],
    CAST(c.NUMERIC_PRECISION AS INTEGER) [Precision],
    CAST(c.DATETIME_PRECISION AS INTEGER) [DateTimePrecision],
    CAST(c.NUMERIC_SCALE AS INTEGER) [Scale],
    c.COLLATION_CATALOG [CollationCatalog],
    c.COLLATION_SCHEMA [CollationSchema],
    c.COLLATION_NAME [CollationName],
    c.CHARACTER_SET_CATALOG [CharacterSetCatalog],
    c.CHARACTER_SET_SCHEMA [CharacterSetSchema],
    c.CHARACTER_SET_NAME [CharacterSetName],
    CAST(0 AS BIT) AS [IsMultiSet],
    CAST(COLUMNPROPERTY(OBJECT_ID(QUOTENAME(c.TABLE_SCHEMA) + '.' + QUOTENAME(c.TABLE_NAME)), c.COLUMN_NAME, 'IsIdentity') AS BIT) AS [IsIdentity],
    CAST(COLUMNPROPERTY(OBJECT_ID(QUOTENAME(c.TABLE_SCHEMA) + '.' + QUOTENAME(c.TABLE_NAME)), c.COLUMN_NAME, 'IsComputed')
    | CASE WHEN c.DATA_TYPE = 'timestamp' THEN 1
    ELSE 0
    END AS BIT) AS [IsStoreGenerated],
    c.COLUMN_DEFAULT AS [Default]
    FROM INFORMATION_SCHEMA.COLUMNS c
    INNER JOIN INFORMATION_SCHEMA.TABLES t
    ON c.TABLE_CATALOG = t.TABLE_CATALOG
    AND c.TABLE_SCHEMA = t.TABLE_SCHEMA
    AND c.TABLE_NAME = t.TABLE_NAME
    AND t.TABLE_TYPE IN ('BASE TABLE', 'VIEW')
    ) AS [Extent2]
    UNION ALL
    SELECT [Extent3].[Id] AS [Id],
    [Extent3].[Name] AS [Name],
    [Extent3].[Ordinal] AS [Ordinal],
    [Extent3].[IsNullable] AS [IsNullable],
    [Extent3].[TypeName] AS [TypeName],
    [Extent3].[MaxLength] AS [MaxLength],
    [Extent3].[Precision] AS [Precision],
    [Extent3].[Default],
    [Extent3].[DateTimePrecision] AS [DateTimePrecision],
    [Extent3].[Scale] AS [Scale],
    [Extent3].[IsIdentity] AS [IsIdentity],
    [Extent3].[IsStoreGenerated] AS [IsStoreGenerated],
    6 AS [C1],
    [Extent3].[ParentId] AS [ParentId]
    FROM (
    SELECT QUOTENAME(c.TABLE_SCHEMA) + QUOTENAME(c.TABLE_NAME) + QUOTENAME(c.COLUMN_NAME) [Id],
    QUOTENAME(c.TABLE_SCHEMA) + QUOTENAME(c.TABLE_NAME) [ParentId],
    c.COLUMN_NAME [Name],
    c.ORDINAL_POSITION [Ordinal],
    CAST(CASE c.IS_NULLABLE
    WHEN 'YES' THEN 1
    WHEN 'NO' THEN 0
    ELSE 0
    END AS BIT) [IsNullable],
    CASE WHEN c.DATA_TYPE IN ('varchar', 'nvarchar', 'varbinary')
    AND c.CHARACTER_MAXIMUM_LENGTH = -1 THEN c.DATA_TYPE + '(max)'
    ELSE c.DATA_TYPE
    END AS [TypeName],
    c.CHARACTER_MAXIMUM_LENGTH [MaxLength],
    CAST(c.NUMERIC_PRECISION AS INTEGER) [Precision],
    CAST(c.DATETIME_PRECISION AS INTEGER) AS [DateTimePrecision],
    CAST(c.NUMERIC_SCALE AS INTEGER) [Scale],
    c.COLLATION_CATALOG [CollationCatalog],
    c.COLLATION_SCHEMA [CollationSchema],
    c.COLLATION_NAME [CollationName],
    c.CHARACTER_SET_CATALOG [CharacterSetCatalog],
    c.CHARACTER_SET_SCHEMA [CharacterSetSchema],
    c.CHARACTER_SET_NAME [CharacterSetName],
    CAST(0 AS BIT) AS [IsMultiSet],
    CAST(COLUMNPROPERTY(OBJECT_ID(QUOTENAME(c.TABLE_SCHEMA) + '.' + QUOTENAME(c.TABLE_NAME)), c.COLUMN_NAME, 'IsIdentity') AS BIT) AS [IsIdentity],
    CAST(COLUMNPROPERTY(OBJECT_ID(QUOTENAME(c.TABLE_SCHEMA) + '.' + QUOTENAME(c.TABLE_NAME)), c.COLUMN_NAME, 'IsComputed')
    | CASE WHEN c.DATA_TYPE = 'timestamp' THEN 1
    ELSE 0
    END AS BIT) AS [IsStoreGenerated],
    c.COLUMN_DEFAULT [Default]
    FROM INFORMATION_SCHEMA.COLUMNS c
    INNER JOIN INFORMATION_SCHEMA.VIEWS v
    ON c.TABLE_CATALOG = v.TABLE_CATALOG
    AND c.TABLE_SCHEMA = v.TABLE_SCHEMA
    AND c.TABLE_NAME = v.TABLE_NAME
    WHERE NOT (
    v.TABLE_SCHEMA = 'dbo'
    AND v.TABLE_NAME IN ('syssegments', 'sysconstraints')
    AND SUBSTRING(CAST(SERVERPROPERTY('productversion') AS VARCHAR(20)), 1, 1) = 8
    ) AS [Extent3]
    ) AS [UnionAll1]
    ON (0 = [UnionAll1].[C1])
    AND ([Extent1].[Id] = [UnionAll1].[ParentId])
    LEFT OUTER JOIN (
    SELECT [UnionAll2].[Id] AS [C1],
    CAST(1 AS BIT) AS [C2]
    FROM (
    SELECT QUOTENAME(tc.CONSTRAINT_SCHEMA) + QUOTENAME(tc.CONSTRAINT_NAME) [Id],
    QUOTENAME(tc.TABLE_SCHEMA) + QUOTENAME(tc.TABLE_NAME) [ParentId],
    tc.CONSTRAINT_NAME [Name],
    tc.CONSTRAINT_TYPE [ConstraintType],
    CAST(CASE tc.IS_DEFERRABLE
    WHEN 'NO' THEN 0
    ELSE 1
    END AS BIT) [IsDeferrable],
    CAST(CASE tc.INITIALLY_DEFERRED
    WHEN 'NO' THEN 0
    ELSE 1
    END AS BIT) [IsInitiallyDeferred]
    FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc
    WHERE tc.TABLE_NAME IS NOT NULL
    ) AS [Extent4]
    INNER JOIN (
    SELECT 7 AS [C1],
    [Extent5].[ConstraintId] AS [ConstraintId],
    [Extent6].[Id] AS [Id]
    FROM (
    SELECT QUOTENAME(CONSTRAINT_SCHEMA) + QUOTENAME(CONSTRAINT_NAME) [ConstraintId],
    QUOTENAME(TABLE_SCHEMA) + QUOTENAME(TABLE_NAME) + QUOTENAME(COLUMN_NAME) [ColumnId]
    FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
    ) AS [Extent5]
    INNER JOIN (
    SELECT QUOTENAME(c.TABLE_SCHEMA) + QUOTENAME(c.TABLE_NAME) + QUOTENAME(c.COLUMN_NAME) [Id],
    QUOTENAME(c.TABLE_SCHEMA) + QUOTENAME(c.TABLE_NAME) [ParentId],
    c.COLUMN_NAME [Name],
    c.ORDINAL_POSITION [Ordinal],
    CAST(CASE c.IS_NULLABLE
    WHEN 'YES' THEN 1
    WHEN 'NO' THEN 0
    ELSE 0
    END AS BIT) [IsNullable],
    CASE WHEN c.DATA_TYPE IN ('varchar', 'nvarchar', 'varbinary')
    AND c.CHARACTER_MAXIMUM_LENGTH = -1 THEN c.DATA_TYPE + '(max)'
    ELSE c.DATA_TYPE
    END AS [TypeName],
    c.CHARACTER_MAXIMUM_LENGTH [MaxLength],
    CAST(c.NUMERIC_PRECISION AS INTEGER) [Precision],
    CAST(c.DATETIME_PRECISION AS INTEGER) [DateTimePrecision],
    CAST(c.NUMERIC_SCALE AS INTEGER) [Scale],
    c.COLLATION_CATALOG [CollationCatalog],
    c.COLLATION_SCHEMA [CollationSchema],
    c.COLLATION_NAME [CollationName],
    c.CHARACTER_SET_CATALOG [CharacterSetCatalog],
    c.CHARACTER_SET_SCHEMA [CharacterSetSchema],
    c.CHARACTER_SET_NAME [CharacterSetName],
    CAST(0 AS BIT) AS [IsMultiSet],
    CAST(COLUMNPROPERTY(OBJECT_ID(QUOTENAME(c.TABLE_SCHEMA) + '.' + QUOTENAME(c.TABLE_NAME)),
    c.COLUMN_NAME, 'IsIdentity') AS BIT) AS [IsIdentity],
    CAST(COLUMNPROPERTY(OBJECT_ID(QUOTENAME(c.TABLE_SCHEMA) + '.' + QUOTENAME(c.TABLE_NAME)),
    c.COLUMN_NAME, 'IsComputed')
    | CASE WHEN c.DATA_TYPE = 'timestamp' THEN 1
    ELSE 0
    END AS BIT) AS [IsStoreGenerated],
    c.COLUMN_DEFAULT AS [Default]
    FROM INFORMATION_SCHEMA.COLUMNS c
    INNER JOIN INFORMATION_SCHEMA.TABLES t
    ON c.TABLE_CATALOG = t.TABLE_CATALOG
    AND c.TABLE_SCHEMA = t.TABLE_SCHEMA
    AND c.TABLE_NAME = t.TABLE_NAME
    AND t.TABLE_TYPE IN ('BASE TABLE', 'VIEW')
    ) AS [Extent6]
    ON [Extent6].[Id] = [Extent5].[ColumnId]
    UNION ALL
    SELECT 11 AS [C1],
    [Extent7].[ConstraintId] AS [ConstraintId],
    [Extent8].[Id] AS [Id]
    FROM (
    SELECT CAST( NULL AS NVARCHAR (1)) [ConstraintId], CAST( NULL AS NVARCHAR (MAX)) [ColumnId] WHERE 1= 2
    ) AS [Extent7]
    INNER JOIN (
    SELECT QUOTENAME(c.TABLE_SCHEMA) + QUOTENAME(c.TABLE_NAME) + QUOTENAME(c.COLUMN_NAME) [Id],
    QUOTENAME(c.TABLE_SCHEMA) + QUOTENAME(c.TABLE_NAME) [ParentId],
    c.COLUMN_NAME [Name],
    c.ORDINAL_POSITION [Ordinal],
    CAST(CASE c.IS_NULLABLE
    WHEN 'YES' THEN 1
    WHEN 'NO' THEN 0
    ELSE 0
    END AS BIT) [IsNullable],
    CASE WHEN c.DATA_TYPE IN ('varchar', 'nvarchar', 'varbinary')
    AND c.CHARACTER_MAXIMUM_LENGTH = -1 THEN c.DATA_TYPE + '(max)'
    ELSE c.DATA_TYPE
    END AS [TypeName],
    c.CHARACTER_MAXIMUM_LENGTH [MaxLength],
    CAST(c.NUMERIC_PRECISION AS INTEGER) [Precision],
    CAST(c.DATETIME_PRECISION AS INTEGER) AS [DateTimePrecision],
    CAST(c.NUMERIC_SCALE AS INTEGER) [Scale],
    c.COLLATION_CATALOG [CollationCatalog],
    c.COLLATION_SCHEMA [CollationSchema],
    c.COLLATION_NAME [CollationName],
    c.CHARACTER_SET_CATALOG [CharacterSetCatalog],
    c.CHARACTER_SET_SCHEMA [CharacterSetSchema],
    c.CHARACTER_SET_NAME [CharacterSetName],
    CAST(0 AS BIT) AS [IsMultiSet],
    CAST(COLUMNPROPERTY(OBJECT_ID(QUOTENAME(c.TABLE_SCHEMA) + '.' + QUOTENAME(c.TABLE_NAME)),
    c.COLUMN_NAME, 'IsIdentity') AS BIT) AS [IsIdentity],
    CAST(COLUMNPROPERTY(OBJECT_ID(QUOTENAME(c.TABLE_SCHEMA) + '.' + QUOTENAME(c.TABLE_NAME)),
    c.COLUMN_NAME, 'IsComputed')
    | CASE WHEN c.DATA_TYPE = 'timestamp' THEN 1
    ELSE 0
    END AS BIT) AS [IsStoreGenerated],
    c.COLUMN_DEFAULT [Default]
    FROM INFORMATION_SCHEMA.COLUMNS c
    INNER JOIN INFORMATION_SCHEMA.VIEWS v
    ON c.TABLE_CATALOG = v.TABLE_CATALOG
    AND c.TABLE_SCHEMA = v.TABLE_SCHEMA
    AND c.TABLE_NAME = v.TABLE_NAME
    WHERE NOT (
    v.TABLE_SCHEMA = 'dbo'
    AND v.TABLE_NAME IN ('syssegments', 'sysconstraints')
    AND SUBSTRING(CAST(SERVERPROPERTY('productversion') AS VARCHAR(20)), 1, 1) = 8
    ) AS [Extent8]
    ON [Extent8].[Id] = [Extent7].[ColumnId]
    ) AS [UnionAll2]
    ON (7 = [UnionAll2].[C1])
    AND ([Extent4].[Id] = [UnionAll2].[ConstraintId])
    WHERE [Extent4].[ConstraintType] = N'PRIMARY KEY'
    ) AS [Project5]
    ON [UnionAll1].[Id] = [Project5].[C1]
    WHERE NOT ([Extent1].[Name] IN ('EdmMetadata', '__MigrationHistory'));
    Thanks in advance.
    UPDATE. I made a quick Google search and found this
    http://stackoverflow.com/questions/1013333/entity-framework-and-sql-server-view/2715299#2715299
    It sounds as an interesting idea to try although I am not sure it will work with POCO Generator. But I'm going to try it now anyway.
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

    UPDATE. Changing my view to be
    USE [SiriusSQL_SysManager]
    GO
    /****** Object: View [dbo].[SiriusV_SalesPointsLicensesList] Script Date: 4/30/2015 1:28:54 PM ******/
    DROP VIEW [dbo].[SiriusV_SalesPointsLicensesList]
    GO
    /****** Object: View [dbo].[SiriusV_SalesPointsLicensesList] Script Date: 4/30/2015 1:28:54 PM ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    create view [dbo].[SiriusV_SalesPointsLicensesList]
    as
    select ISNULL(salespoint,'') as Salespoint
    , CAST(loc_suffix as smallint) as Id
    , CAST(descrip as varchar(25)) as [Description]
    , cast(mode as tinyint) as Mode
    , cast(is_access as bit) as AccessWare
    , cast(is_adv_inv as bit) as AdvInventory
    , cast(is_cw_crdt as bit) as CardwareCredit
    , cast(is_debit as bit) as DebitWare
    , cast(is_dir_net as bit) as DirectNet
    , cast(is_fbquick as bit) as FBQuickService
    , cast(is_fbtable as bit) as FBTableService
    , cast(is_grpschd as bit) as ResourceScheduling
    , cast(is_guests as bit) as Guests
    , cast(is_pass as bit) as PassWare
    , cast(is_pms as bit) as PMSInterface
    , cast(is_rental as bit) as RentWare
    , cast(is_dual as bit) as DualBook
    , cast(is_pod as bit) as PodBook
    , cast(is_private as bit) as PrivateBook
    , cast(is_resrv as bit) as Reservations
    , cast(is_teesht as bit) as TeeSheet
    , cast(is_rungk as bit) as RunGKInSales
    , cast(is_resseat as bit) as ReservedSeating
    , cast(is_kcashls as bit) as KioskCashless
    , cast(is_ksales as bit) as KioskSales
    , cast(is_kwilcal as bit) as KioskWillCall
    , cast(is_payplan as bit) as PaymentPlan
    , cast(is_test as bit) as Test
    from dbo.sales_pt
    where hidden = 0 ;
    GO
    worked!!! I now have just salespoint as the Key.
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • How can I use the SQL to create a primary key for a existing table?

    create table a(bm number,mc varchar2(20));
    when the table was created,i want to make the column bm as
    the primary key and my SQL is "alter table a enable primary key bm",the system show
    me error,how can I write the right one?

    create table a(bm number,mc varchar2(20));
    when the table was created,i want to make the column bm as
    the primary key and my SQL is "alter table a enable primary key bm",the system show
    me error,how can I write the right one? You do not have any primary key defined on your table yet, so, it does not make sense to enable it (if at all possible) !
    You need to add PRIMARY KEY using something like this:
    SQL> alter table a add constraint pk_a_bm primary key (bm) ;

  • How to create a primary key or foreign key

    in the table student, sid should be the primary key
    in the table prerequisite cnum should be the foreign key and prereq the primary key
    please help me with the syntax thanks.

    As I said in your other post, it's all in the docs, go first to http://tahiti.oracle.com and try to find the answer yourself
    http://download-uk.oracle.com/docs/cd/B10501_01/server.920/a96540/clauses3a.htm#1002630

  • How can I be able to create a primary key in a Form on a Table with Report?

    When I click the "Create" button, a form appears allowing me type in data for those columns. But primary key is not there. I really need to specify my primary key here also. Because the primary key for this table is a Serial Number, not just a sequence number.
    I noticed that when I created this page earlier, the primary key was ruled out by default. I wish there is a way to accomplish this. Thanks!

    Hello,
    >> a pk field is not null implicit …
    I’m not sure I understand your statement. Every item, including the one holds the primary key, is null for a new form. The question is, when you are filling the form, how to populate this field. The APEX wizard assumes this field will be populated by the system, hence it hides it from the user, however it’s a valid situation where the primary field is filled by the user.
    As primary field should not be changed, hence the productive advice by Martin. If the form displays an existing record, the primary field item should be set to Read Only.
    Regards,
    Arie.
    Please remember to mark appropriate posts as correct/helpful. For the long run, it will benefit us all.

  • How to create one primary key for each vendor

    Hi all
    i am doing IDOC to jdbc scenario
    i am triggering idoc from R/3 and the data is going into DB table vendor through XI.
    structures are as follows:
    sender side: ZVendorIdoc (this is a customized IDOC , if i triger IDOC for multiple vendors then it triggers only 1 idoc with multiple segment )
    Receiver side:
    DT_testVendor
        Table
            tblVendor
                action UPDATE_INSERT
                access                     1:unbounded
                    cVendorName         1
                    cVendorCode        1
                    fromdate                1
                    todate                    1
                 Key1
                    cVendorName         1
    if i trigger idoc for multiple vendors ,for example vendor 2005,2006 and 2010 . then i can see that the only key comes from the very first field (2005) and the whole record for vendor 2005,2006 and 2010  goes into the table with this(2005) as a primary key
    now again if i send data for these three vendor 2005, 2006 , 2010, in which record for the vendor 2005 is same and for 2006 and 2010 are different than it takes 2005 as a primary key and it does not update the data in the table.
    my requirement is like this:   for each vendor there should be one unique key assigned.
                                              for above said example there should come three keys one for each vendor .
    could you please help me how to do this???????????

    Hi,
      In Mapping Make the statement is 0-unbounded.For each vendor create a statement.This will solve your problem.
    Regards,
    Prakasu.M

  • Calling a page after creating a primary key?

    Hello,
    I have a form on a table with a create button on it. The primary key is created after I click the CREATE button, and brings me back to the report which shows my new record. Everything is fine here.
    Now, I want to branch to a new page (after processing), while passing the value of my new primary key to this page. But it seems that this value is null (if I look in the URL there's no value)
    For example, I need to create a new Client, and pass the primary key of my client to a new page. But it doesn't work... anybody can help me?
    Thanks,
    Mathieu

    Never, EVER use the current value + 1!!! You will at some point, run into a collision, where two records are trying to use the same primary key value!
    If you are using a surrogate PK, then you may want to consider using an Oracle sequence and trigger to populate that value. If you create a simple table via SQL Workshop, APEX will create not only a table, but the associated sequence and trigger; have a look at that if you have not seen this in action.
    If you prefer to not use a trigger, then yes, you can have a computation that sets the value of P4_NOCLIENT to the next value of the sequence - NOT the current value + 1. Once it's set in APEX session state, the rest is pretty simple.
    Thanks,
    &#150; Scott &#150;
    http://spendolini.blogspot.com/
    http://sumnertech.com/

Maybe you are looking for