【IT支援部】MySQL クエリ色々

Author:

個人的な備忘録。
とりあえず忘れないように今まで打ったコマンド適当に書き連ねる。

create database DB名;
drop databese DB名;
create table rss_user_info ( user_id int primary key, password varchar(32) );
create table users (id int not null primary key auto_increment,
password varchar(32),
created datetime,
modified datetime);
mysql>; insert into rss_user
    ->; (user_id, user_name, password)
    ->; values
    ->; (1, 'name', 'pass');
alter table テーブル modify column カラム integer auto_increment;
grant all privileges on *.* to pma@localhost with grant option;
set password for pma@localhost = password('pmapass');

create table feed (
id int unsigned not null auto_increment,
feedid varchar(64) not null,
name varchar(64) not null,
userid varchar(32) not null,
link varchar(1024),
created_time datetime default "2012-10-14 12:00:00",
update_time datetime default "2012-10-14 12:00:00",
title varchar(128),
mainmsg text,
likes int unsigned default 0,
primary key(id)
); 

create table comment (
feedid varchar(64) not null,
name varchar(32) not null,
userid varchar(32) not null,
created_time datetime default "2012-10-14 12:00:00",
commentmsg text,
likes int unsigned default 0,
foreign key(feedid)
references feed
);

alter table feed add unique (feedid);
update テーブル SET a=1;
Facebook にシェア
Pocket

コメントを残す