First of all, installing the MySQL Data Base Management System is a straightforward process. I used Synaptic to install the mysql-server and mysql-client packages on my Linux platform. If you use Windows you can visit the download page at mysql.com.
This is an example of a simple MySQL session. The commands are self-explanatory. If you need a little bit more of a walk-through, the "MySQL Tutorial for beginners" series on YouTube is a step-by-step description of most of the commands that follow.
1. Creating a database and adding tables to it (8:49 min)
2. Adding data to tables in a database (5:49 min)
3. Selecting data from tables in a database (4:14 min)
4. Updating data in a database (3:37 min)
5. Deleting data from a database (5:46 min)
### Start mySQL
mysql -u root
### Create a database
show databases;
create database example;
use example;
show tables;
### Create a table in the database
create table users(id int(12) unsigned auto_increment primary key not null, password varchar(25) not null, email varchar(40) not null);
show tables;
describe users;
### Add the column "username" which was
### forgotten when defining the table
alter table users add username varchar(25) not null;
describe users;
alter table users drop column username;
describe users;
alter table users add username varchar(25) not null after id;
describe users;
### Populate the table
insert into users(username, password, email) values('alice', '123', 'alice@gmail.com');
select * from users;
insert into users(username, password, email) values('bob', '234', 'bob@gmail.com');
insert into users(username, password, email) values('charlie', '345', 'charlie@gmail.com');
insert into users(username, password, email) values('donna', '456', 'donna@gmail.com');
insert into users(username, password, email) values('evan', '567', 'evan@gmail.com');
### Explore the table
select * from users;
select username from users;
select * from users where id=1;
select * from users where username='charlie';
select username from users order by username;
### Change some fields
update users set email='robert@gmail.com' where username='bob';
update users set passwd='123';
### Delete some rows and columns
delete from users where username='alice';
select * from users;
delete from users where username in('bob','charlie');
alter table users drop column email;
### Delete the whole database
drop database example;
show databases;
Wow! this is Amazing! I got free 10,000 instagram followers! Click here to get your free instagram followers!
ReplyDeleteReally when someone doesn't understand then its up to other viewers that they will assist, so here it takes place.
ReplyDelete