Techblog

Technical Blog about all things computer

  • Sep 16

    MYSQL Basic Tutorial

    The aim of this tutorial is to help you familiarize with basic MYSQL commands.

    1.) How to show the available databases.

    show databases;

    2.) How to create a database. For example you want to create a database called “test_database”

    create database test_databaseee;
    3.) Oops. You made a spelling mistake, test_database has extra e’s. To drop database use

    drop database test_databaseee;
    4.) To create test_database again type:

    create database test_database;
    5.) To select a database so you can access the tables without a database prefix:

    use test_database;
    6.) To show available tables in a database.

    show tables;
    7.) To create a table:

    create table test_table (

    name varchar(50),

    age int);
    8.) To look at the columns and structure of the table you just created:

    show table test_table;

    9.) To insert data to the table created above:

    insert into test_table(name, age)

    values (‘Bill Gates’, 50);

    10.) To insert multiple values into a table, separate the values by a comma:

    insert into test_table (name, age)

    values (‘Steve Balmer’, 55),

    (‘Larry Ellison’, 51),

    (‘Albert Einstein’, 100);

    11.) To view the data in your table:

    select * from test_table;
    12.) To delete a record from your table. For example you want to delete “Bill Gates” from the example above:

    delete from test_table

    where name = ‘Bill Gates’;

    13.) To update a column in a table. For example you want to update Albert Einstein’s age:

    update test_table set age = ‘200’ where name = ‘Albert Einstein’;

    Hope this tutorial was helpful. Feel Free to post your questions and I will answer them.