Basics on tables in Mysql

Navigating around in mysql is quite easy. You can see which databases by using the command “show databases“. There will always exist a database called “mysql” which is used by mysql itself.

If your user account has access to a database, you can access it by using the “use DATABASENAME” command. You can se which tables exist within a database by using the “show tables” command – and see details for each table by issuing the “desc TABLENAME” command.

changing Tables

All alterations of database tables is done with the alter table command. The main challenge is use the command beyond just making it work. Here’s a few clues to get the most of it.

Let’s make a simple table as an example:

CREATE TABLE demotable (
id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY);

Adding a column

ALTER TABLE demotable ADD COLUMN label CHAR(20);

More…

Find more details in the Mysql manual.