I'm doing a database in MySQL with MySQL Worbench and I wonder how you can help me in my database.
What is the default / expression field used for when creating a table?
I'm doing a database in MySQL with MySQL Worbench and I wonder how you can help me in my database.
What is the default / expression field used for when creating a table?
The default / expression attribute sets the default value for the column when an insert is not provided.
For example given the following table:
CREATE TABLE persona
(nombre char(50),
apellidos char(50),
direccion char(50) default 'desconocida',
pais char(50) default 'España');
Yes we make an insert
INSERT INTO persona (nombre, apellidos)
VALUES ( 'Pedro', 'Picapiedra');
It will generate the following record:
nombre | apellido | direccion | país
---------------------------------------------
Pedro | Picapiedra | desconocida | España