As for postgres, mssql, and for oracle, change the null property on the not null column and then check all the properties of this column in ALL databases? One change request. And one to check for type and length, and is nullable.

  • one
    What does it mean to “check”, if you try to make the column not null, and it will be null at that moment, the request simply will not work - Mike
  • In the sense of? Yes, in direct! It is necessary to take a column and find out what properties are currently set for it. Of course the request will not work, and? - alex safsafsd
  • ... and everything. The properties of a column can be viewed in the system view ALL_TAB_COLUMNS . The rest of the DBMS - look in their documentation. There is no unified way. For change, formally, you can write a more or less standard DDL query, but I will not give a guarantee that it will work the same everywhere. - Dmitriy
  • And what is the "All" column properties, it seemed like it was not null, what other properties are of interest - Mike
  • @mike you do not know what are the properties of the columns? - alex safsafsd

1 answer 1

Changing X column property to not null:

 Oracle: alter table test modify X not null; Ms sql: alter table test alter column X VARCHAR not null; Postgresql: alter table test alter column X set not null; 

As can be seen from the example, in the case of using MS SQL, it is impossible to directly set the attribute NOT NULL without specifying the data type of the column.

Information on data types, length, NOT NULL attribute on columns can be obtained as follows:

 Oracle: select * from ALL_TAB_COLUMNS where owner='владелец' AND table_name='таблица' and column_name='колонка' Ms sql и Postgresql: select * from information_schema.columns where table_schema='схема' AND table_name = 'таблица' AND column_name = 'колонка';