Prepare for your Next Interview
|
Welcome to the Geeks Talk forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
This is a discussion on Sql Questions For You within the SQL forums, part of the Databases category; 1.> Can We update a View. 2.> How will You establish many to many relationship in sql. 3.>write sql statement for deleting duplicates values in table....
|
|||||||
|
|||
|
1.> Can We update a View.
2.> How will You establish many to many relationship in sql. 3.>write sql statement for deleting duplicates values in table. |
| The Following User Says Thank You to aman15490 For This Useful Post: | ||
| Sponsored Links |
|
|||
|
Re: Sql Questions For You
SQL Statements for deleting duplicate values?
SQL> delete from table_name where rowid not in (select max(rowid ) from table group by duplicate_values_field_name); or SQL> delete duplicate_values_field_name dv from table_name ta where rowid <(select min(rowid) from table_name tb where ta.dv=tb.dv); Example. Table Emp Empno Ename 101 Scott 102 Jiyo 103 Millor 104 Jiyo 105 Smith delete ename from emp a where rowid < ( select min(rowid) from emp b where a.ename = b.ename); The output like, Empno Ename 101 Scott 102 Millor 103 Jiyo 104 Smith |
|
|||
|
Re: Sql Questions For You
can we update a view?
we can replace a view. ie when we create it if we specify replace then if the view exists then it is replaced by other and if not a new view is created. |
|
|||
|
Re: Sql Questions For You
a join view can't be updated if it contains
--------------------------- 1.hierarchical query clause start with & connect by 2.group by & order by. 3.model query. 4.set operations. 5.aggragate functions 6.a subquery or a collection expresion in the select list. 7.the distinct operator 8.the rownum pseudo column 9.read only option. A dml statment on a join view can modify only one base table of the view .to be modifiable,a join view must preserve a key from at least one of its tables. ------ key-preserved table ------------ in a join,a table is called a key-preserve table if its keys are preserved through the join.every key of the table can also be a key of the resultant join resultset.every primary key or unique key value in the base table must also be unique in the result set of the join. A)key-preservation is a property of the table inside the join view not the table itself independently.a table may be key preseved in one join view and may not be key preserved in another join view. B)it is not necessary for the key columns of a table to be selected in the join view for the table to be key preserved. C)if the key columns of a table is selected in the view defination ,it does not make the the table key preserved. D)the key-preserved property of the table in a join view does not depend on the data inside the table.it depends on the schema design and the relationship between the tables. E)a join view may select data from many tables ,any dml operation can modify data from only one underlying table. F)user can't refer to the columns of a non-key-preserved table in an insert statement. G)delete operation can be performed on a join view if the join view has one and only one key-preserved table. Many to many relationship depends on database architecture. Try this sample sql statement for deleting duplicates values in table. ------------------------------------------------------------------ Code:
Delete from emp e where rowid>(select min(rowid) from emp where e.empno=empno) OR Delete from emp where rowid not in(select max(rowid) from emp group by empno) NOTE:------This is oracle query. |
| The Following 3 Users Say Thank You to debasisdas For This Useful Post: | ||
|
|||
|
you can update a simple view(update v_t1 set sal=200 where sal=50000) but complex view(have join from two or more table) is not updatble
u can delete duplicate row from table vai these commands 1)create table t2 as select distinct * from t1; 2) drop table t1; 3)rename table t2 to t1; |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| my questions.... | Abhisek Bhattacharjee | Oracle | 2 | 03-08-2009 08:58 PM |
| jsp questions | dhanyasraj | JSP | 3 | 10-01-2008 11:19 AM |
| OS Questions | JobHelper | Windows | 5 | 05-15-2008 02:10 AM |
| Bo questions | alvi.jayasudha | Data Warehousing | 1 | 12-13-2007 04:48 AM |
| HR questions | sakshi_2801 | Brainteasers | 1 | 06-20-2007 02:31 AM |