The Default / expression field in MySQL (Worbench) What is it for?

0

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?

    
asked by CesarG 25.05.2017 в 21:05
source

1 answer

1

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
    
answered by 25.05.2017 / 21:21
source