TAILIEUCHUNG - Oracle SQL Plus The Definitive Guide- P14

Oracle SQL Plus The Definitive Guide- P14:Every day, computer professionals the world over wake up, travel to the office, sit down in front of a computer, and begin another day working with that database called Oracle. Programmers write queries and stored procedures. Database administrators monitor performance, make database changes, and perform other maintenance tasks. Operations people may need to back up or recover a database. | previous page page_107 next page Page 107 that returns the current date and use the NEW_VALUE clause of the COLUMN command to get that date into a user variable. That user variable sticks around for the duration of the session and can be used in a subsequent report. Getting the date from Oracle The built-in SYSDATE function is used in the following example to return the current date from the database. Notice that the NEW_VALUE option of the COLUMN command is used to update the user variable report_date with the current value of SYSDATe as returned from the database. COLUMN SYSDATE NEW_VALUE report_date SELECT SYSDATE FROM DUAL SYSDATE is an Oracle built-in function that returns the current date and time. DUAL is a special Oracle table that always exists always contains exactly one row and always contains exactly one column. You could select SYSDATE from any other table but DUAL works well because it returns only one rowall you need to set the date. The date returned using this method is the date on the database server not the client. If you are using a PC to access data on a remote database in a different time zone the date returned may or may not match the local date. This depends on the time of day when the report is run and on the number of hours difference between the time zones. Formatting the date You may find that the date format returned by SYSDATE is not what you would prefer. It depends on the setting of the NLS_dAtE_FORMAT parameter which can vary from one database to the next. You can use the ALTER SESSION command to specify a different format for example ALTER SESSION SET NLSDATEFORMAT DD-Mon-YYYY ALTER SESSION changes the format for the duration of the SQL Plus session. Make sure you execute it prior to selecting SYSDATE from DUAL. Another alternative is to use the built-in TO_CHAR function to specify a format. COLUMN current_date NEW_VALUE report_date SELECT TO_CHAR SYSDATE DD-Mon-YYYY current_date FROM DUAL A column alias of current_date was used .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.