Create a primary key in the oracle view and a primary key in the oracle View

Source: Internet
Author: User
Tags oracle materialized view

Create a primary key in the oracle view and a primary key in the oracle View

A project requires a view to create a primary key. The following is an example.

CREATE or replace VIEW SME_V_A... (AGENTID, AGENTNAME, BUSYNUM, RESTNUM, RESTTIME, DEVICENONUM, DEVICENOSUM
, CONSTRAINT AGENTSTATIC_PK primary key (AGENTID) rely disable novalidate)
AS
Select a. AGENTID as AGENTID, --- Agent ID
(Select B. OPERATOR_NAME
FROM CC_AGENT_INFO B
Where B. WORK_NO = A. AGENTID) AS AGENTNAME, ---- agent name
NVL (SUM (C. BUSYNUM), 0) as busynum, ----- indicates the number of busy times
NVL (SUM (C. RESTNUM), 0) as restnum, ------ Number of breaks
NVL (SUM (C. RESTTIME), 0) as resttime, ------ rest duration (minutes)
NVL (D. DEVICENO_NUM, 0) as devicenonum, ------- total number of calls
NVL (D. DEVICENO_SUM, 0) as devicenosum ------- total session duration
FROM CC_V _...
Left join ......
Left join ......
Group by a. AGENTID, D. DEVICENO_NUM, D. DEVICENO_SUM;

 

Check whether a primary key exists.

select a.constraint_name, a.column_name  from user_cons_columns a, user_constraints b 
where a.constraint_name = b.constraint_name  
 and b.constraint_type = 'P'   and a.table_name = 'SME_V_A....'


 


Primary Key Issues in the oracle View

You can add a primary key on your own, or add a primary key when generating this view !!

Why can't I automatically create a primary key on the local oracle materialized view?

Are you sure the tables on the two servers are the same?
Check it carefully!
 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.