Jump to content

MySql - Coluna aceita NULL no update


jfosorio
 Share

Recommended Posts

Boas,

Devo confessar que estou um pouco perturbado com este problema. Então não é que no mysql, um atributo pode ser actualizado com o valor NULL, apesar de estar definido como NOT NULL!!! Isto é de loucos! Ou o meu phpmyadmin está a bater mal, ou então o mysql ficou lerdinho!  😛

Será que alguém já se deparou com este problema e sabe como dar-lhe a volta?

Já agora, estou a usar o storage engine InnoDB (caso seja útil a informação).

CSS 3D Text - Partilha mensagens em 3D com os teus amigos no Facebook!

Portal de Informática it4life - Emprego, notícias, fórum, comunidade.

Link to comment
Share on other sites

Sinceramente, não sei o que estou a fazer errado. O comando que estou a utilizar é o seguinte:

UPDATE delegados SET nome_delegado = NULL WHERE id_delegado = 4;

O campo nome_delegado está definido como not null.

Mas quando executo este comando, o campo fica vazio.

Nem sei o que vos diga... 😕

CSS 3D Text - Partilha mensagens em 3D com os teus amigos no Facebook!

Portal de Informática it4life - Emprego, notícias, fórum, comunidade.

Link to comment
Share on other sites

Deixa-me adivinhar, fica com o valor que está definido como default e lança um aviso.

Inserting NULL into a column that has been declared NOT NULL. For multiple-row INSERT statements or INSERT INTO ... SELECT statements, the column is set to the implicit default value for the column data type. This is 0 for numeric types, the empty string ('') for string types, and the “zero” value for date and time types. INSERT INTO ... SELECT statements are handled the same way as multiple-row inserts because the server does not examine the result set from the SELECT to see whether it returns a single row. (For a single-row INSERT, no warning occurs when NULL is inserted into a NOT NULL column. Instead, the statement fails with an error.)

"[Os jovens da actual geração]não lêem porque não envolve um telecomando que dê para mirar e atirar, não falam porque a trapalhice é rainha e o calão é rei" autor: thoga31

Life is a genetically transmitted disease, induced by sex, with death rate of 100%.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.