Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
0
Alter table tablename add columnname datatype(size)
20th Jan 2021, 2:30 AM
Krishna Kumar
Krishna Kumar - avatar
+ 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...?
18th Jan 2021, 8:45 PM
Josh Greig
Josh Greig - avatar
+ 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.
19th Jan 2021, 10:53 PM
Josh Greig
Josh Greig - avatar
+ 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
29th Jan 2021, 2:17 AM
Gaurav Juwekar
+ 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
7th Jul 2021, 7:28 AM
Elwyn Ynion
Elwyn Ynion - avatar
0
I don't know how many times I did this just due to a typo. smh
22nd Jan 2022, 10:41 AM
Brian Comly
Brian Comly - avatar