Mega Code Archive

 
Categories / Oracle PLSQL / Date Timezone
 

Use the Timestamp data type in a table and insert data

SQL>  create table conference_calls (   2        title   varchar2(100),   3        phone   varchar2(20),   4        place   varchar2(100),   5        starts  timestamp with time zone)   6    / Table created. SQL> SQL>  insert into conference_calls (title, phone, place, starts)   2      values ('Sales Strategy', '212.123.4567', 'Washington',   3              TIMESTAMP '2001-12-01 15:00:00.000000 EST')   4      / 1 row created. SQL> SQL> insert into conference_calls (title, phone, place, starts)   2   values ('Product Features', '650.123.4567', 'San Francisco',   3              TIMESTAMP '2001-12-01 17:00:00.000000 PST')   4    / 1 row created. SQL> SQL> insert into conference_calls (title, phone, place, starts)   2      values ('Football Highlights', '44 1234 5678', 'London',   3              TIMESTAMP '2001-12-01 20:00:00.000000 GMT')   4    / 1 row created. SQL> SQL> SQL> select * from conference_calls; TITLE                                                                                                PHONE ---------------------------------------------------------------------------------------------------- -------------------- PLACE                                                                                                STARTS ---------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------- Sales Strategy                                                                                       212.123.4567 Washington                                                                                           01-DEC-01 03.00.00.000000 PM EST Product Features                                                                                     650.123.4567 San Francisco                                                                                        01-DEC-01 05.00.00.000000 PM PST Football Highlights                                                                                  44 1234 5678 London                                                                                               01-DEC-01 08.00.00.000000 PM GMT SQL> SQL> select title, phone   2        from conference_calls   3        where starts = TIMESTAMP '2001-12-01 15:00:00.000000 -5:00'   4    / TITLE                                                                                                PHONE ---------------------------------------------------------------------------------------------------- -------------------- Sales Strategy                                                                                       212.123.4567 Football Highlights                                                                                  44 1234 5678 SQL> SQL> drop table conference_calls; Table dropped. SQL> SQL>