Tongda OA mysql adds a column of commands at a certain position in the table to be judged by a program.
You have to write a document and use a program in the middle to determine whether a Column exists. If it does not exist, add the document. If it does not exist, simply display a result. The written program is as follows:
If exists (select * from information_schema.columns where table_name = "flow_process" and column_name = "X_test2" AND table_schema = 'td _ OA ') then
Alter table flow_process add column X_test2 tinyint (1) null default 0 after X_ifMonitor;
Else
Select "already exists ";
End if;
However, an error is always prompted during execution. There is no problem with executing the content in the brackets of exists. After finding relevant information, the original method can only be used in the stored procedure, and the mysql version must be later than 5.0. Then such a program cannot be written and can only be judged manually.
Modify the SQL statement of a mysql DATA table:
Directly add columns:
Alter table flow_process add column X_test2 tinyint (1) null;
Add columns after a column in the table:
Alter table flow_process add column X_test2 tinyint (1) null default 0 after X_ifMonitor;
Add to the first column:
Alter table flow_process add column X_test2 tinyint (1) null first;