Sybase 12.4.2 User Manual

Page of 536
Changing data using UPDATE
224
 
The Append_Load option applies to 
LOAD
INSERT...SELECT
, and 
INSERT...VALUES
 statements.
For more information on versioning see Chapter 8, “Transactions and 
Versioning”.
Changing data using UPDATE
You can use the 
UPDATE
 statement, followed by the name of the table or view, 
to change single rows, groups of rows, or all rows in a table. As in all data 
modification statements, you can change the data in only one table or view at 
a time.
The 
UPDATE
 statement specifies the row or rows you want changed and the 
new data. The new data can be a constant or an expression that you specify or 
data pulled from other tables.
If an 
UPDATE
 statement violates an integrity constraint, the update does not 
take place and an error message appears. For example, if one of the values 
being added is the wrong data type, or if it violates a constraint defined for one 
of the columns or data types involved, the update does not take place.
UPDATE syntax
See the Adaptive Server IQ Reference Manual for complete 
UPDATE
 syntax. A 
simplified version of the syntax is: 
UPDATE 
table-name 
SET 
column_name = expression
WHERE 
search-condition
If the company Newton Ent. (in the customer table of the sample database) is 
taken over by Einstein, Inc., you can update the name of the company using a 
statement such as the following: 
UPDATE customer
SET company_name = ’Einstein, Inc.’
WHERE company_name = ’Newton Ent.’
You can use any condition in the WHERE clause. If you are not sure how the 
company name was entered, you could try updating any company called 
Newton, with a statement such as the following:
UPDATE customer
SET company_name = ’Einstein, Inc.’
WHERE company_name LIKE ’Newton%’