ALTER TABLE Normarashod MODIFY nomoper int CHECK (VALUE > 0) ; 

Why does an error occur if I use CHECK (VALUE> 0)? It works without it. How to fix?

  • What is CHECK in MySQL? In the [documentation] [1], not a word about him ... [1]: - KiTE
  • @KiTE Well, in the description of CREATE TABLE there is such a phrase: The CHECK clause is parsed but ignored by all storage engines. - alexlz
  • @alexlz, yeah, found thanks. The parser understands ADD CHECK and ADD CONSTRAINT name CHECK , but adds nothing to the structure. Dummy. - KiTE
  • @KiTE Myskl is Myskl. An excerpt from the postgresql tutorial: CHECK (expression) Expressions evaluating to TRUE or UNKNOWN succeed. If you want to make a difference, it’s not a problem and it doesn’t alter the database ... - alexlz

2 answers 2

And if so?

 ALTER TABLE Normarashod MODIFY nomoper int, ADD CHECK (VALUE > 0) ; 

    If I understand correctly, do you need to change the field type? If yes, then such a request will help you:

     ALTER TABLE Normarashod CHANGE nomoper nomoper VARCHAR(100) 

    Edit the table "Normarashod", change the field "nomoper" to "nomoper" (without renaming) with the new type "VARCHAR (100)"

    • You misunderstand, a question about another - KiTE
    • I will not dispute. Only now I would like to clarify a little question. - AseN