0
s_no    s_name       s_father
-------------------------------
1       ram          mohan
2       hareesh      galla
3       praveen      nagaraj
4       mallikarju   bandaru
5       yashas       penubakam

现在我想将 DOB 列添加到现有表中。如何将 DOB 列添加到现有表中,应使用哪种数据类型?

4

1 回答 1

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

我强烈建议查看文档

于 2013-07-31T11:02:41.513 回答