GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Oracle  >  SQL Plus
Go To First  |  Previous Question  |  Next Question 
 SQL Plus  |  Question 25 of 132    Print  
If unique key constraint on DATE column is created, will it validate the rows that are inserted with SYSDATE

  
Total Answers and Comments: 7 Last Update: September 04, 2008   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
June 10, 2005 06:16:00   #1  
sajida        

RE: If unique key constraint on DATE column is created, will it validate the rows that are inserted with...
Yes.
 
Is this answer useful? Yes | No
September 15, 2005 10:21:34   #2  
indu        

RE: If unique key constraint on DATE column is created...
It won't Because SYSDATE format contains time attached with it.
 
Is this answer useful? Yes | No
May 11, 2006 14:06:51   #3  
rajani        

RE: If unique key constraint on DATE column is created...

i think it will not allow .

If the date format is dd-mon-yy the timestamp will be 00:00:00.then we cannot enter sysdate for unique date column.

if we set the NLS_DATE_FORMAT to DD-MON-YY HH:MI:SS

then we can enter sysdate into the rows of a column with uinque constraint. so sysdate value will not be the same always.


 
Is this answer useful? Yes | No
May 18, 2006 06:56:06   #4  
rajaselviv        

RE: If unique key constraint on DATE column is created...
if ur answer is Yes tell us the reason
 
Is this answer useful? Yes | No
November 10, 2006 06:57:59   #5  
Vamseek Member Since: November 2006   Contribution: 4    

RE: If unique key constraint on DATE column is created...

Yes It will validate the rows inserted using sysdate.

sysdate is a function which will returs the operating system's date.

You can use sysdate if you are inserting one record at a time but you can't use sysdate if you are bulk inserting into that table (It will throw an unique constraint violation exception).

-Vamsee


 
Is this answer useful? Yes | No
June 17, 2008 06:53:40   #6  
lovely sethii Member Since: June 2008   Contribution: 3    

RE: If unique key constraint on DATE column is created, will it validate the rows that are inserted with SYSDATE
yes it will
 
Is this answer useful? Yes | No
September 04, 2008 17:04:00   #7  
Gayathri Panchangam Member Since: August 2008   Contribution: 2    

RE: If unique key constraint on DATE column is created, will it validate the rows that are inserted with SYSDATE
Yes.

Becoz sysdate contains date and time.

For example: if u create a table like this

create table ex(id number date1 date defualt sysdate unique);

u get table created. After that if u insert rows in that table

insert into ex(id) values (id);
enter id:1
1 row created...
SQL>/
enter id:2
1 row created .....

like this u insert some rows into that table

If u want to view the table type select * from ex; then u will get the result like this

id date1

1 sep-4-08
2 sep-4-08
........

if u want to view the date colum with time also u have to alter the session like this

alter session set nls_date_format 'mm-dd-yy hh24:mi:ss';

u get session altered. now type the above SQL command

select * from ex;

id date1
----------------------------------

ID DATE1
---------- -----------------
1 09-04-08 16:40:03
2 09-04-08 16:40:05
3 09-04-08 16:40:06
4 09-04-08 16:40:08
5 09-04-08 16:40:10
6 09-04-08 16:40:12
7 09-04-08 16:40:16
8 09-04-08 16:40:18
9 09-04-08 16:40:20
10 09-04-08 16:40:21


Like this we can create date column with unique constraint.




 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape