17,089
社区成员
发帖
与我相关
我的任务
分享
SQL>
SQL> create table Custom_Table(
2 user_id number primary key,
3 user_name varchar2(20) not null,
4 user_birthday date not null
5 );
Table created
SQL> insert into Custom_Table values(
2 1, 'zhangsan',
3 (select nvl(max(user_birthday) + 1 / 86400, date'2018-06-02') from Custom_Table)
4 );
1 row inserted
SQL> insert into Custom_Table values(
2 2, 'lisi',
3 (select nvl(max(user_birthday) + 1 / 86400, date'2018-06-02') from Custom_Table)
4 );
1 row inserted
SQL> select user_id, user_name, to_char(user_birthday, 'yyyy-mm-dd hh24:mi:ss') x
2 from Custom_Table;
USER_ID USER_NAME X
---------- -------------------- -------------------
1 zhangsan 2018-06-02 00:00:00
2 lisi 2018-06-02 00:00:01
SQL> drop table Custom_Table purge;
Table dropped
SQL>