Use the Timestamp data type in a table and insert data : Timestamp « Date Timezone « Oracle PL / SQL






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>

           
       








Related examples in the same category

1.TIMESTAMP specifies a precision for the SECONDS field in a TIMESTAMP column (the DATE data type can only store whole seconds).
2.Compare data and timestamp
3.INSERT statement adds a row with the TIMESTAMP keyword to supply a datetime literals
4.Use the TIMESTAMP type to define a column in a table
5.TIMESTAMP WITH TIME ZONE type extends TIMESTAMP to allow you to store a time zone
6.TIMESTAMP(4) WITH TIME ZONE
7.Cast string to TIMESTAMP
8.Use TIMESTAMP to mark string in insert statement
9.TIMESTAMP WITH LOCAL TIME ZONE
10.Use timestamp as table column type and insert sysdate to it
11.Create a table with two columns: 'timestamp with time zone', 'c2 timestamp with local time zone'