Use Trunc in insert statement : INSERT with Functions « Insert Delete Update « Oracle PL / SQL






Use Trunc in insert statement

 
SQL>
SQL>
SQL> CREATE TABLE product (
  2       product_name     VARCHAR2(25),
  3       product_price    NUMBER(4,2),
  4       quantity_on_hand NUMBER(5,0),
  5       last_stock_date  DATE);

Table created.

SQL>
SQL> INSERT INTO product VALUES ('S', 99, 1, '15-JAN-03');

1 row created.

SQL> INSERT INTO product VALUES ('M', 75, 1000, '15-JAN-02');

1 row created.

SQL> INSERT INTO product VALUES ('C', 50, 100, '15-JAN-03');

1 row created.

SQL> INSERT INTO product VALUES ('R', 25, 10000, null);

1 row created.

SQL> INSERT INTO product VALUES ('S', 45, 1, trunc(sysdate));

1 row created.

SQL>
SQL> DROP TABLE product;

Table dropped.

 








Related examples in the same category

1.You can use variables such as SYSDATE and USER in your INSERT statements
2.Inserting values using System function: SYSDATE
3.Date calculation in insert statement