Wednesday, July 1, 2009

How to use MYSQL Database – command prompt

Today i want to test MySQL database

I use mysql-4.1.22-win32, setup and after install it,  i go to 
image 

and it will display this window (need password) if you use it setting :
image 
default window will appear like this:
image 
after that we learn about command syntax on mysql

to know mysql version we can use this syntax:
mysql> select version();

image

to display database that exist:
mysql> show databases;
image

to create new database:
mysql> create database practise01;
image

to change to database that you want to choose:
mysql> use practise01;
image

to create new table:
mysql> create table tblTest01(id int);
image

to show table structures:
mysql> describe tbltest01;
or
mysql> show columns from tbltest01;
image

to show tables that exist:
mysql> show tables;
image

to alter table structure:
mysql> alter table tbltest01 add nama varchar(20);
image

to fill your data table:
mysql> insert into tbltest01(id,nama) values(1,"jimon");
point : insert into tablenm(col1,col2,…) values(datacol1,datacol2,…)
image 

to display data from current table:
mysql> select * from tbltest01;
image 

to update data from current table:
mysql> update tbltest01 set id=3,nama="cyntia" where nama="cintia";
image

to close window mysql command prompt:
mysql> exit;

ok have a nice try, hope this will help you to know mysql better.

1 comment:

Rara said...

Thank you for Select a MySQL database to use tutorial.