INTERVAL YEAR(3) TO MONTH
SQL> CREATE TABLE coupons (
2 coupon_id INTEGER,
3 name VARCHAR2(30),
4 duration INTERVAL YEAR(3) TO MONTH
5 );
Table created.
SQL>
SQL>
SQL> INSERT INTO coupons (coupon_id, name, duration) VALUES (1, '$1 off Z Files', INTERVAL '1' YEAR);
1 row created.
SQL> INSERT INTO coupons (coupon_id, name, duration) VALUES (2, '$2 off Pop 3', INTERVAL '11' MONTH);
1 row created.
SQL> INSERT INTO coupons (coupon_id, name, duration) VALUES (3, '$3 off Modern Science', INTERVAL '14' MONTH);
1 row created.
SQL> INSERT INTO coupons (coupon_id, name, duration) VALUES (4, '$2 off Tank War', INTERVAL '1-3' YEAR TO MONTH);
1 row created.
SQL> INSERT INTO coupons (coupon_id, name, duration) VALUES (5, '$1 off Chemistry', INTERVAL '0-5' YEAR TO MONTH);
1 row created.
SQL> INSERT INTO coupons (coupon_id, name, duration) VALUES (6, '$2 off Creative Yell', INTERVAL '123' YEAR(3));
1 row created.
SQL>
SQL> SELECT * FROM coupons;
COUPON_ID NAME DURATION
---------- ------------------------------ ---------------------------------------------------------------------------
1 $1 off Z Files +001-00
2 $2 off Pop 3 +000-11
3 $3 off Modern Science +001-02
4 $2 off Tank War +001-03
5 $1 off Chemistry +000-05
6 $2 off Creative Yell +123-00
6 rows selected.
SQL>
SQL>
SQL>
SQL> drop table coupons;
Related examples in the same category