Access OA MySQL add a column of commands to a table at a certain point in the program to judge the problem

Source: Internet
Author: User
Tags mysql version

Originally to write a document, the middle of the program to determine whether a column exists, does not exist to add, there is no processing directly display a result can be, write the program as follows:

if exists (SELECT * FROM information_schema.columns WHERE table_name = "flow_process" and column_name = "X_test2" and TA Ble_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, the execution of the time has been prompted with errors. Exists () there is no problem with content execution within parentheses. After finding the relevant information, the original writing can only be used in the stored procedure, and requires that the MySQL version needs to be above 5.0. Then such a program can not write, only artificial to judge.


To modify the SQL statement for the MySQL data table:

Add directly to the column:

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;

Access OA MySQL add a column of commands to a table at a certain point in the program to judge the problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.