Decimal default value : Decimal « Data Type « SQL / MySQL






Decimal default value

      
mysql>
mysql> CREATE TABLE PENALTIES
    ->       (PAYMENTNO     INTEGER NOT NULL PRIMARY KEY,
    ->        EmployeeNO      INTEGER NOT NULL,
    ->        PAYMENT_DATE  DATE NOT NULL DEFAULT '1990-01-01',
    ->        AMOUNT        DECIMAL(7,2) NOT NULL DEFAULT 50.00)
    -> ;
Query OK, 0 rows affected (0.00 sec)

mysql> INSERT   INTO PENALTIES
    ->         (PAYMENTNO, EmployeeNO)
    -> VALUES  (15, 27)
    -> ;
Query OK, 1 row affected (0.00 sec)

mysql> INSERT   INTO PENALTIES
    ->         (PAYMENTNO, EmployeeNO, PAYMENT_DATE, AMOUNT)
    -> VALUES  (15, 27, DEFAULT, DEFAULT);
ERROR 1062 (23000): Duplicate entry '15' for key 'PRIMARY'
mysql>
mysql> drop table penalties;
Query OK, 0 rows affected (0.00 sec)

mysql>

   
    
    
    
    
    
  








Related examples in the same category

1.Decimal and Numeric Data Field Syntax When 123.4567 Is Inserted
2.NUMERIC, DEC Synonym for DECIMAL
3.DECIMAL(p, s) Fixed-point number, saved as a character string;
4.DECIMAL(4,2) for price
5.Insert value to a decimal value column
6.DECIMAL(7,2)
7.DECIMAL(7,2) ZEROFILL NOT NULL
8.Update decimal value