以下是一个简单测试,用于说明Decode函数的用法:SQL> create table t as select username,default_tablespace,lock_date from dba_users;Table created.SQL> select * from t;USERNAME DEFAULT_TABLESPACE LOCK_DATE------------------------------ ------------------------------ ---------SYS SYSTEMSYSTEM SYSTEMOUTLN SYSTEMCSMIG SYSTEMSCOTT SYSTEMEYGLE USERSDBSNMP SYSTEMWMSYS SYSTEM 20-OCT-048 rows selected.SQL> select username,decode(lock_date,null,'unlocked','locked') status from t;USERNAME STATUS------------------------------ --------SYS unlockedSYSTEM unlockedOUTLN unlockedCSMIG unlockedSCOTT unlockedEYGLE unlockedDBSNMP unlockedWMSYS locked8 rows selected.SQL> select username,decode(lock_date,null,'unlocked') status from t;USERNAME STATUS------------------------------ --------SYS unlockedSYSTEM unlockedOUTLN unlockedCSMIG unlockedSCOTT unlockedEYGLE unlockedDBSNMP unlockedWMSYS8 rows selected.