Select a Category

Common SQL Statements

Adding Comments to SQL Statements

In line comment start with two –, example Select StudentName from Student where ID=’5′ –This shows student name with student ID 5;

Block or Multi-Line comment with /* and */, example /* This shows student name with student ID 5 */ Select StudentName from Student where ID=’5′;

Select Command Select […]

Common MySQL Operations

Here are some common MySQL Operations

Log into MySQL with following command: mysql -u root -p

Create a new database name sample: create database sample;

Create a sample user in local host with password ‘secret’: create user sample@localhost identified by ‘secret’;

Grant all Privileges to sample user on database sample: grant All Privileges on sample.* […]

How to Contruct Multi-Line MySQL Script


You want to run multiple MySQL commands in sequence constantly. You can type them in one by one, which is time consuming and subjected to errors. Or you can encapsulate them in a script.


Here is one example of a Multi-Line MySQL script:

mysql –user=’username’ –password=’userpassword’ <<sqlscript use sample_database UPDATE comments […]