MySQL文の整理

889 ワード

1.データベースの表示
show DATABASES;

2.表の表示
show tables

3.表の列の表示
show columns from jieyu

4.データベースの作成
create database jiritoutiao charset = utf8;

5.データベースの使用
use jiritoutiao;

6.テーブルの作成
create table shop(
  id int not null auto_increment,
  name char(20) not null ,
  url char(50) not null ,
  primary key (id)
) engine  = innodb default charset utf8;
create table goods(
  id int not null auto_increment,
  name char(20) not null ,
  url char(50) not null ,
  shop_id int not null ,
  primary key (id)
) engine  = innodb default charset utf8;

7.テーブル構造の変更
alter table goods add price char(20);

8.列の削除
alter table shop drop column goods_nums;

9