New course! Every coder should learn Generative AI!
Try a free lesson0
Alter table tablename add columnname datatype(size)
+ 3
You're unable to alter a table?
The SQL alter table statement is explained in simple terms here:
https://www.w3schools.com/sql/sql_alter.asp
If you have a specific table structure and a specific alter table statement that isn't working, share them. Share a "show table create" result for the table. Share the statement that is failing. Also, share what vender of SQL you're using. Is it MySQL, Oracle, SQL Server...?
+ 2
If you want to add a column, check the link I posted earlier.
If you want to insert specific data, that's an insert statement. Adding a column and inserting data needs to be a separate SQL statement.
You still didn't say precisely what your table structure is or your SQL vendor. If you're trying to just get a very abstract understanding and don't care about actually running SQL statements, change that. Actually install some SQL server and get this working. It is much easier to learn SQL by actually using it than just reading about it and thinking about it. Actually running it and having a solid, specific, reproducible problem also helps people like me help you. A problem you just imagine to exist is very difficult for me to solve.
+ 2
I am having the same issue. its not an issue with the ALTER TABLE , but using the UPDATE to add values to this new column as per the ask.
how to add specific multiple string values in the column for multiple WHERE conditions. i am able to do it for just single values with single where condition
+ 2
ALTER TABLE cities ADD attractiveplace VARCHAR (255);
UPDATE cities
SET attractiveplace = 'Belem Tower'
WHERE name = 'Lisbon';
UPDATE cities
SET attractiveplace = 'Plaza Mayor'
WHERE name = 'Madrid';
UPDATE cities
SET attractiveplace = 'Eiffel Tower'
WHERE name = 'Paris';
SELECT * FROM cities
0
I don't know how many times I did this just due to a typo. smh