ecommerce MySQL Cheat Sheet and Examples

Cheat Sheet

mysql command prompt

To connect to the m server use the command line:

mysql -u username -h hostname -p databasename

You will be prompted for your password when you log on. If you need to change which database you are using use the command:

mysql>use databasename

Table creation

To create a table the command is:

mysql>create table table_name ( column specs ) ;

To see a description of a table that you have created:

mysql>describe table_name ;

List tables

To display the tables in a database use the command:

mysql>show tables;

Insert

To insert into a table:

mysql>insert into table_name values(your_values_go_here,more_values),(another_row);

or

mysql>insert into table_name (column_names) values(...);

Select

To select data from a table use a select command:

mysql>select what_to_select from tables_to_use where conditions_are_met ;

Delete

To delete data:

mysql> delete from table_name where conditions_are_met;



© 1996 -- 2005, Noel Schutt
E-mail me at: ski ihatespam at schutt dot org
(hint: delete " ihatespam " , and replace " at " with "@" and " dot " with ".")
Page last updated: 2004.03.31