cat-right

SQL Tutorials...

These simple SQL tutorials are designed for new users. While these commands are basic, they can help you come to grips with the way the language works.

How to Use the REPLACE Command

This command works like the find and replace feature in spreadsheets and word processors. The syntax is:

REPLACE(string, old_string, new_string);

You can use the REPLACE command with SET and UPDATE. These can be used to update data in a table. For instance:

UPDATE movies SET director = REPLACE(director, George Lucas’, ‘Steven Spielberg’);

This query informs MySQL an update will be made for the “director” field in the “movie” table. Then it will replace all George Lucas entries with Steven Spielberg.

Note: it is best to be specific with the REPLACE command. This way you don’t accidentally overwrite other data.

How to Change Passwords

MySQL (this SQL tutorial is for Windows users)

Step 1

Click the Start button and click Run. Type the following:

C:Program FilesMySQLMySQL Server 5.0inmysqld

Replace the C with the drive letter where the program is stored. After typing the command, the MySQL command line will pop up.

Step 2

Type this in the command line:

mysqladmin -u <user> password new_password

Put your username in lieu of <user>. Type the new password.

Step 3

Press the Enter key. The password change will be reflected in the SQL server.

SQL Server

Step 1

Click the Start button and go to “All Programs”. Look for SQL Server” then “SQL Server Management Studio”. The SQL server console will open.

Step 2

Open a new window by clicking “New Query”. Type the following:

alter login <user> with password = ‘<new_password>’;

Replace <user> with the username that will be edited. Enter the new password.

Step 3

Press F5. The changes will now take effect.

How to Access the Run Command with Interactive SQL

Step 1

Click Start and go to “All Programs”. Look for “SQL Anywhere 9”. Choose “SQL Anywhere 9” then “Adaptive Server Anywhere”. Click “Interactive SQL”.

Step 2

Click “File” and choose “Run Script”. Go through the SQL command file. Click “Open”.

Tip:

The SQL statement widow can be used to run commands. The command is:

READ c:xxxxxx.sql

Links to More tutorials

If you are looking for more info, the following SQL tutorial links may prove useful:

www.sql-tutorial.net/

www.sqltutorials.net/

www.tizag.com/sqlTutorial/

www.baycongroup.com/tocsql.htm

Using a search engine you will come across many more tutorials that will help you understand how to use the language.

Just remember to take your time. By going over the commands carefully, the various functions and commands will be easier to understand.