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

Feedback

Input format: The editor controls below will assist with Markdown syntax.

Status

Sub-status

Your info

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.

Contact Matt

Similar Entries

Stats

1 unique visit since October 2008

Recent Referrers (click)

Syndicate

Advertisements