3

I have an SQL statement without a where clause because I want it to affect all rows. I have a column with the name url. Now I want to change the current column url to something else. I want to concatenate something to the current url.

My statement is:

 UPDATE tablename SET url = 'http' || url;

This is in a sql file, which executes and throws no errors but the database is not changing.

Can anyone help?

RDBMS is MySQL

4
  • 7
    What RDBMS to be sure? Commented Sep 19, 2011 at 18:33
  • 2
    tsql uses ( + ) for concat... are you using oracle... or some other sql language? in tsql the || is a bitwise operator Commented Sep 19, 2011 at 18:35
  • 1
    Also, how are you running the file? Commented Sep 19, 2011 at 18:36
  • 1
    Certainly that code will not work with all SQL databases. It would fail in SQL Server for instance that uses a + for concatentation. Commented Sep 19, 2011 at 19:05

3 Answers 3

3

Depending on your engine (in case it isn't Oracle and you have some bizarre MySQL bitwise operator)

UPDATE tablename SET url = CONCAT('http', url);

or

UPDATE tablename SET url = 'http' + url;
Sign up to request clarification or add additional context in comments.

1 Comment

@user953278: Thanks What RDBMS though please?
3

(Assuming its an Oracle DB)
I guess you are not commiting the changes and checking for the changes in other session.

Change your script file to:

UPDATE tablename SET url = 'http' || url; 
COMMIT;

Comments

2

You may need to commit the transaction if commit is not implicit. Try

COMMIT;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.