Simple SQL changes Mar01 '05
When working in SQL – your tables, columns, and actual data will often need to be changed.
As perfect as you think that table structure is, it most definitely will change at least once – as you learn more, or figure out more efficient ways to manage your data.
Here, I include the SQL syntax for three of the most basic updates that you can perform – to modify your table name, a specific column, or an actual piece of data in a table that has already been created.
Change the table name
ALTER TABLE table_name RENAME new_table_name
Change the name of a column (field)
ALTER TABLE table_name CHANGE old_column_name new_column_name [column attributes, etc.]
Notice you have to repeat the column attributes when renaming a column. You can’t just change the name, and be done.
Change a piece of data
UPDATE table_name SET column_name WHERE [conditional statements]
Categories: SQL ![]()
Add Feedback (view all)
Leave feedback
matthom
is published and produced by Matt Thommes - an independent publishing enthusiast, mobile blogger, content creator, informative writer, web developer from Chicago.
Never one to conform, Matt intends to promote the effect the web has on our lives, in an effort to intensify, instruct, and clarify all that is happening around us.
Similar Entries
- Full date to SQL date within Excel (228 recent visits)
- SQL – select greatest value (1160 recent visits)
- SQL: update field value to itself (943 recent visits)
- iTunes SQL (128 recent visits)
- SQL: Think Optimize! (1 recent visits)
- Excel and SQL (649 recent visits)
Stats
1 unique visit since October 2008