Thanks for the question, shankar.
Asked: January 19, 2016 - 6:43 pm UTC
Last updated: January 20, 2016 - 2:43 am UTC
Version: 11g
Viewed 1000+ times
You Asked
can we create a table with default keyword when using subquery?
Ex: create table emp(empno,sal,hiredate default sysdate)
as
select employee_id,salary
from employees;
I am not selecting hiredate from employees and i am assuming it to take default value. However, the above query is failing. How can I accomplish this to take the default value. Can we use default constraint when creating table using subquery? Please advise.
Best Regards,
Shankar
and Connor said...
You "almost" can do it in the way you specified. You still need to have the default in the select, ie
<code>
SQL> create table emp(empno,sal,hiredate default sysdate)
2 as
3 select employee_id,salary,sysdate
4 from hr.employees;
Table created.
<code>
Is this answer out of date? If it is, please let us know via a Comment