Re: Valor predeterminado fech en MySQL
| From: | Satyam | Date: | Mon, 22 May 2006 10:27:55 +0000 |
| Subject: | Re: Valor predeterminado fech en MySQL | ||
| References: | 1 | Groups: | php.general.es |
| Request: | Send a blank email to general-es+get-58902@lists.php.net to get a copy of this message | ||
El mismo manual te lo dice:
The DEFAULT clause specifies a default value for a column. With one exception, the default value must be a constant; it cannot be a function or an expression. This means, for example, that you cannot set the default for a date column to be the value of a function such as NOW() or CURRENT_DATE. The exception is that you can specify CURRENT_TIMESTAMP as the default for a TIMESTAMP column. See Section 11.3.1.1, "TIMESTAMP Properties as of MySQL 4.1".
o sea, solo admite constantes, no funciones, o sea, no puedes usar now() o current_date, pero si puedes usar current_timestamp para una columna de tipo timestamp, que justamente para eso está.
Dice también:
DEFAULT NULL is the same as DEFAULT CURRENT_TIMESTAMP for the first TIMESTAMP column. For any other TIMESTAMP column, DEFAULT NULL is treated as DEFAULT 0.
O sea, que para la primer columna de tipo timespamp cuyo default sea null es lo mismo que declararlo como current_timestamp. Subsiguientes columnas del mismo tipo con default null recibiran cero.
Satyam
----- Original Message ----- From: ""Fco. Javier Sánchez-Ostiz Erviti"" <desarrollo@inmonet.net>
To: <php-es@lists.php.net>
Sent: Monday, May 22, 2006 11:08 AM
Subject: [PHP-ES] Valor predeterminado fech en MySQL
Buenos días desde pamplona a la gente de la lista. Hace tiempo que no participo y me asombra el nivel que cada día tienen los temas que se tratan. Yo voy con una pregunta sencilla aunque creo que este no es el foro adecado. Me gustaría poner en un campo tipo fecha de mysql una valor por defecto que tome la fecha en la que se inserte la fila, sé que con php se puede hacer con date(), pero ¿y con MySQL? Un saludo y gracias; Spielberg -- PHP Spanish Localization Talk Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php