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






Date default value

    
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)

   
    
    
    
  








Related examples in the same category

1.Date type value in the form '2003-12-31', range 1000-01-01 to 9999-12-31 (3 bytes)
2.To find the row with the most recent birth date, the query is similar, except that you sort in descending orde
3.Compare with Date value
4.How MySQL deals with incorrect date value
5.Date literal in where clause
6.Date value literal
7.Date type value inside in operator and subquery
8.Date calculation with variable
9.Sorting by Calendar Day