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

  • SEARCH
  • Home
  • 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 7050699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:10:30+00:00 2026-05-28T03:10:30+00:00

I have t1 table having no number(3) and name varchar2(20) columns And emp table

  • 0

I have t1 table having no number(3) and name varchar2(20) columns

And emp table having empno,ename,job etc columns.

Now I am creatng a view

create view v_t as select * from t1,emp;

It creates view. Then I am trying to insert values inside v_t that is view but it gives me error that

cannot modify a column which maps to a non key-preserved table

here is one link

What am I doing wrong?

  • 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-05-28T03:10:30+00:00Added an answer on May 28, 2026 at 3:10 am

    Assuming that both the t1 table and emp table have primary keys that the view can identify as unique, I’m going to guess that the issue is with how you are specifying your JOIN. What you’ve got right now looks like it will create a Cartesian product (every row from one table indiscriminately joined to every row from the other), and that’s probably not going to satisfy the key-preserved table requirement (referenced in the question that you linked above).

    You are specifying an implicit JOIN in your FROM clause, but I don’t see any JOIN conditions (read: WHERE clause). By looking at your schema, I’m going to assume that you can JOIN on t1.no = emp.empno like this:

    create view v_t as 
    select * 
    from t1,emp
    where t1.no = emp.empno;
    

    Or with an explicit JOIN:

    create view v_t as
    select *
    from t1
    inner join emp on emp.empno = t1.no;
    

    Oracle will allow a NATURAL JOIN (without specifying JOIN conditions) on tables that have columns of the same type and name. Of course, since no and empno have different names, that’s not going to work.

    Now that your CREATE VIEW is squared-away, let’s get to the INSERT. You can INSERT into a VIEW based on a JOIN as long as the table is key-preserved and you don’t try to INSERT to more than one base table at once. Which in your case means writing two separate INSERT statements or writing an INSTEAD OF trigger:

    CREATE TRIGGER v_t_insteadof
    INSTEAD OF INSERT ON v_t
    
    FOR EACH ROW
    BEGIN 
    
    INSERT INTO t1 (no, name)
    VALUES(:new.no, :new.name); 
    
    INSERT INTO emp (empno, ename, job)
    VALUES(:new.no, :new.ename, :new.job); 
    
    END v_t_insteadof;
    

    Note, that you’ll need to adjust the INSERT INTO emp based-on the additional fields that might exist in that table. Also, your INSERT command will need to specifically name the fields:

    INSERT INTO v_t (no, name, ename, job) VALUES (59, 'Bob', 'Bobs Ename', 'Bobs Job');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table named with Sales having the following columns: Sales_ID|Product_Code|Zone|District|State|Distributor|Total_Sales Now i
I have a mysql table having register number, dob, student name, sex, total mark
Suppose I have a table Item (Id int Primary Key, Number INT) having records
I have a table having 2 columns EmployeeId (int) and EmployeeDetails(XMl type) EmployeeId EmployeeDetails
I have table A and table B with Table A having several columns including
I have 3 columns in Oracle database having table mytable and i want records
Suppose I have the following table: PARAMETER - NAME varchar2(10) - TABLE_NAME varchar2(50) -
I have a database table that stores document information (DocID, Name, Type, Owner, etc).
I have a table 'books'. For simplicity, here are 3 columns: name(text) | new(boolean)
I have a table having column name NAME ========= GAURAV GAURAV AJAY AJAY ===========

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.