You are on page 1of 2

---MYSQL---

--UPDATE (MULTIPLE)—
--CREATE DATABASE—
mysql> update tbl_custmr set lastname =
mysql> create database db_sample; case custmr_id
-> when 1 then "bajadiii"
--CREATE TABLE— -> when 2 then "santiago"
mysql> create table tbl_custmr( -> when 7 then "mariano"
-> custmr_id int(3) auto_increment, -> else lastname
-> lastname varchar(20) not null, -> end,
-> cell_no int(12) not null, -> cell_no = case custmr_id
-> primary key (custmr_id)); -> when 1 then 09123456789
-> else cell_no
--INSERT— -> end
mysql> insert into tbl_custmr -> where custmr_id in (1, 2, 7);
-> (lastname, cell_no)
-> values --DELETE—
-> ("bajado", 0912345678), mysql> delete
-> ("ocenar", 0998754211); -> from tbl_custmr
-> where custmr_id = 1;
--UPDATE—
mysql> update tbl_custmr --ALTER (column name)—
-> set mysql> alter table tbl_custmr
-> lastname = "bajads", -> change cell_no
-> cell_no = 0912 -> cellnumber int(12);
-> where custmr_id = 1;
--ALTER( column name[multiple column])— --SET PRIMARY KEY USING ALTER—
mysql> alter table tbl_custmr mysql> alter table tbl_custmr
-> change lastname last_name -> change custmr_id
varchar(20),
-> customer_id int(2),
-> change cell_no cell_number int(12);
-> add primary key (customer_id);

--DROP COLUMN—
mysql> alter table tbl_custmr
-> drop column cell_no;

--DROP COLUMN (multiple column)—


mysql> alter table tbl_custmr
-> drop column lastname,
-> drop column cell_no;

--ADD COLUMN—
mysql> alter table tbl_custmr
-> add column address varchar(20) not
null
-> after cell_no;

--ADD COLUMN (multiple column)—


mysql> alter table tbl_custmr
-> add column age int(2) not null,
-> add column gender varchar(6) not null
-> after cell_no;

You might also like