insert server_id in the creation of each record, mysql

1

I have a table in mysql whose records can be created from different servers, these servers are configured as master and slave, and the id of each server was set to 1 , 2 , 3 e etc. I would like to know if it is possible to set the default value of a column to get the server_id of the server that is inserting the record, something automatic type the auto increment.

I tried:

ALTER TABLE 'mytable' 
ADD COLUMN 'somecolumn' TINYINT NULL DEFAULT server_id

But it does not work.

    
asked by anonymous 29.06.2018 / 12:43

1 answer

3
ALTER TABLE 'minhaTabela' 
ADD 'coluna' TINYINT NULL DEFAULT server_id

Try without using ADD COLUMN and use only ADD

    
29.06.2018 / 12:50