MySQL

表の表示を縦表示にする

研究室の人に教えてもらった。カラムが多いDBを扱うときには、見やすくなって便利ー。 文の最後に\Gをつける!

ActiveRecordによるデータベースへのアクセス

Rubyプログラム中でDBと接続する方法使用するテーブル(mysql) create table customers( id int(5), name varchar(255), address varchar(255), primary key(id) ); Rubyプログラム require "rubygems" require "active_record" ActiveRecord::Base.establish…

MySQL:テーブル作成

2つの項目をPrimaryKeyにする create table test( NAME char(5) not null, TEL char(12) not null, primary key(NAME,TEL) );

MySQLコマンドメモ(2)

テーブルの情報を知る show table status; カラムの情報を表示する show columns from [テーブル名] テーブルの行数をカウントする select count(*) from [テーブル名] where [条件]

MySQLコマンドメモ(1)

insert文 insert into [テーブル名] values(値); select文 select [カラム名] from [テーブル名] where [条件]; パターンマッチによるselect文 select [カラム名] from [テーブル名] where [カラム名] regrexp [正規表現]; 結果をソートして返すselect文 sel…

DBI

接続 use DBI; $db = DBI -> connect('DBI:mysql:server_name','user_name','passwd') || die "$!"; eval{ $sth = $db -> prepare(命令文); $sth -> execute; $sth -> finish; $db -> disconnect; }; if($@){ $db -> rollback; $db -> disconnect; } 取り出…