You are on page 1of 1

users

id int primary
username varchar(255) unique
email varchar(255) not null DEFAULT 'name@gmail.com' (may be)

create tabel<tb_name>(<colname><type> primary key auto_increment,........varchar


(255) unique);
alter table <tb_name> add <col_name> <type>; //(<type=timestamp>
describe now(); show time)
alter table <tb_name> modify <col_name> <type>; (unique,primary,increment)
alter table <tb_name> drop <col_name>;
alter table <tb_name> change <old col_name><new col_name><type>;

alter table <tb name> add foreign key<col name> references <tb name>(<col name>);
create table posts (id int primary key auto_increment,title varchar(255),content
text,created_at timestamp,user_id int,foreign key (col name) references users(id));

You might also like