insert server_id in the creation of each registry, mysql

Asked

Viewed 35 times

-1

I have a table on mysql whose records can be created from different servers, these servers are configured as master and slave, and the id of each server has been defined as 1, 2, 3 etç. I wonder if it is possible to set the default value of a column to take the server_id from the server that is entering the log, something automatic like auto increment.

I tried to:

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

But it doesn’t work.

1 answer

1


ALTER TABLE `minhaTabela` 
ADD `coluna` TINYINT NULL DEFAULT server_id

Try without using ADD COLUMN and uses only ADD

Browser other questions tagged

You are not signed in. Login or sign up in order to post.