Sunday, April 24, 2011

MySQL step by step lesson 2

¨After you have connected successfully, you can disconnect any time by typing QUIT (or \q) at the mysql> prompt:
  mysql> QUIT
  Bye
          or
  mysql>Exit

¨To see a list of options provided by mysql, invoke it with the help option:
  mysql> help          or    /h

Creating and Using a Database

¨Use the SHOW statement to find out what databases currently exist on the server:
  mysql> SHOW DATABASES;
¨To access any database use:
  mysql> USE test
  Database changed
ØCreate a text file to save your work                                                
mysql>TEE h:\commands.txt; (can give any name for the text file)-kind of a log file.

¨Type ‘\c’ to clear the buffer(/Clear the current input statement)
¨To create a database                                                      mysql>CREATE DATABASE dbbb;
¨Your commands should always end with a semicolon(;)
¨Spaces aren’t allowed in the names of databases & tables.So an underscore(_) can be used instead.                                         ex:db_cc

¨SQL is case insensitive.That means it’s not necessary to capitalize commands,but it’s considered as a good programming practice in SQL.
¨When naming  tables & databases stick to one naming covention.
¨To view all the available tables in your databases                               
     
mysql>SHOW TABLES;