MySQL Clients: Dropping DB and table

This entry is part 7 of 8 in the series MySQL Clients

Now that we know that the database allartist and a table known as artist have been created. ┬áLet’s drop them and recreate them.

Since there is a table known as artist that is attached to the database allartist, we would have to first drop table artist.

To drop the table, execute the command:

use allartist
drop table artist

Next we drop the database using the command:

drop database allartist

console_drop

 

MySQL Clients: Creating DB and table

This entry is part 8 of 8 in the series MySQL Clients

Using an earlier example, let’s go ahead and create a database and a table.

We will use the same code illustrated in the example.

CREATE TABLE artist
    (
 id int auto_increment primary key, 
 artiste varchar(30), 
 album varchar(50),
 price decimal(3, 2) 
 );
  
INSERT INTO artist
(artiste, album, price)
VALUES
('Rod Stewart', 'Maggie May', 8.90 ),
('New Order', 'Substance', 7.50),
('Nirvana', 'Smell Like Teen Spirit', 9.80);

First create the database using

create database allartist

console_create

Now we create a table and insert a row into it.

We need to use use allartist to ensure that the table is created under the table allartist.

console_createtable

console_insert

We can use select * from artist to check if the table has the inserted data.