I have the following query for mysql but when doing it it gives me an error.
ALTER TABLE conexion ADD
panel_web varchar (255),
panel_web1 varchar (255),
panel_web2 varchar (255),
puerto_panel varchar (255);
The question is how do I add multiple columns using the same query? (that same one works fine for me in SQL server 2008 r2 but in mySQL it doesn't work)
I appreciate the support.
I tried this other one that they told me here but it does not work, it gives me an error
ALTER TABLE conexion ADD
panel_web varchar (255) AFTER
panel_web1 varchar (255)AFTER
panel_web2 varchar (255) AFTER
puerto_panel varchar (255);
[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'varchar (255)AFTER panel_web2 varchar (255) AFTER
Try adding the syntax
ADD COlUM
to each new column you want to addhere you have the official documentation
ALTER TABLE
to make mysqlOnly as a complement:
I would do them
ADD COLUMN
strictly indicating how I want my columns to be , indicating for example if I want them to accept null values or not, if I want them to beUNSIGNED
, etc. Using theAFTER
is also a good option, to be sure that the columns will be inserted where I want them to be inserted.Example:
Demo REXTESTER
Result
A database stores its data in tables.
A table is a data structure that organizes data into columns and rows; each column is a field (or attribute) and each row is a record. The intersection of a column with a row contains a specific data, a single value.
Each record contains data for each column of the table.
Each field (column) must have a name. The name of the field refers to the information that it will store.
Each field (column) must also define the type of data it will store.
When creating a table we must decide what fields (columns) it will have and what type of data each of them will store, that is, its structure.
The table must be defined with a name that identifies it and with which we will access it.
We create a table called "users", we type:
To use ALTER TABLE:
And you can also run multiple transactions with: