s_no s_name s_father
-------------------------------
1 ram mohan
2 hareesh galla
3 praveen nagaraj
4 mallikarju bandaru
5 yashas penubakam
现在我想将DOB列添加到现有表中。如何将DOB列添加到现有表中以及应使用哪种数据类型?
答案 0 :(得分:0)
这是一个例子
SQL> create table t1 (id number);
Table created.
SQL> insert into t1 values (1);
1 row created.
SQL> commit;
Commit complete.
SQL> select * from t1;
ID
----------
1
SQL> alter table t1 add update_date date;
Table altered.
SQL> desc t1
Name Null? Type
------------------------ --------
ID NUMBER
UPDATE_DATE DATE
SQL> update t1 set update_date = to_date('01/01/2013','dd/mm/yyyy');
1 row updated.
SQL> commit;
Commit complete.
SQL> select * from t1;
ID UPDATE_DATE
---------- -------------------
1 01/01/2013 00:00:00
SQL> select id , update_date , to_char(update_date , 'dd-MON-yyyy') as formated_update_date from t1;
ID UPDATE_DATE FORMATED_UP
---------- ------------------- -----------
1 01/01/2013 00:00:00 01-JAN-2013
我强烈建议您查看documentation