1. 为计算的列起别名
SQL> column ename heading "Employee"
SQL> column sal heading "Salary"
SQL> column raise heading "Raise"
2.To_char function
SQL> select PRODUCT_NAME,
2 to_char(PRODUCT_PRICE, '$9,999.00') "Price",
3 to_char(QUANTITY_ON_HAND, '999,999') "On Hand",
4 ' '|| to_char(LAST_STOCK_DATE, 'MON DD, YYYY') "Last Stocked"
5 from PRODUCT;
PRODUCT_NAME Price On Hand Last Stocked
------------------------- ---------- -------- --------------
Small Widget $99.00 1 JAN 15, 2003
Medium Widget $75.00 1,000 JAN 15, 2002
Product Number $50.00 100 JAN 15, 2003
Round Church Station $25.00 10,000
3.TO_CHAR(last_stock_date, 'MM-DD-YYYY HH24:MI') with column alias
SQL> SELECT product_name,
2 product_price,
3 quantity_on_hand,
4 TO_CHAR(last_stock_date, 'MM-DD-YYYY HH24:MI') "Last Stocked"
5 FROM product;
PRODUCT_NAME PRODUCT_PRICE QUANTITY_ON_HAND Last Stocked
------------------------- ------------- ---------------- ----------------
Small Widget 99 1 01-15-2003 00:00
Medium Widget 75 1000 01-15-2002 00:00
Product Number 50 100 01-15-2003 00:00
Round Church Station 25 10000