Microsoft SQL Server
なにかと便利になってきたデータベース。
サーバ
クライアント

■エディションと機能

最大メモリ最大利用可能コアデータベースサイズManagement
Studio
全文検索Reporting
Services
Reporting Services
(SharePoint連携)
Express1GB1cpu/4coreまで10GB××××
Express with Tools1GB1cpu/4coreまで10GB×××
Express with
Advanced Services
1GB1cpu/4coreまで10GB×
Standard64GB4cpu/16coreまでほぼ無制限

■phpでバイナリ―データを扱う
データ登録
$i=1;
$f="imagefile.png";
$dsn = "sqlsrv:server=localhost\express;database=ChEMBL_13";
$dbh=new PDO($dsn,'foo','bar');
$dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$sth = $dbh->prepare("INSERT into IMAGETBL(ID, snapshot) values ( ?, ?)");
$fp = fopen($f,'rb');
$sth->bindParam(1, $id, PDO::PARAM_INT);
$sth->bindParam(2, $fp, PDO::PARAM_LOB,0,PDO::SQLSRV_ENCODING_BINARY );
$dbh->beginTransaction();
$sth->execute();
$dbh->commit();

データ参照
$dsn = "sqlsrv:server=localhost\express;database=ChEMBL_13";
$dbh=new PDO($dsn,'foo','bar');
$dbh->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$sth=$dbh->prepare("SELECT snapshot FROM IMAGETBL where ID=1");
$sth->execute();
$sth->bindColumn(1,$image,PDO::PARAM_LOB,0, PDO::SQLSRV_ENCODING_BINARY);
$sth->fetch(PDO::FETCH_BOUND);
file_put_contents("imagefile.png",$image);

メモ

小ネタ
■連番を振る
UPDATE table_a
SET table_a.ID=tmp.idx
FROM (
SELECT table_a.ID,table_a.MOL, ROW_NUMBER() OVER (ORDER BY table_a.ID,table_a.MOL) AS idx
FROM table_a
) AS tmp
WHERE
table_a.ID=tmp.ID AND table_a.MOL=tmp.MOL

■縦に複数のデータを横並びで取得したい
https://webbibouroku.com/Blog/Article/forxmlpath

最新の60件
2023-09-20 2023-09-19 2023-09-18 2023-09-17 2023-09-16 2023-09-14 2023-09-12 2023-09-11 2023-09-08 2023-09-05 2023-09-02 2023-08-30 2023-08-29 2023-08-28 2023-08-27 2023-08-22 2023-08-20 2023-08-18 2023-08-17 2023-08-14 2023-08-12 2023-08-09 2023-08-07 2023-08-06 2023-08-03 2023-07-31 2023-07-29 2023-07-27 2023-07-25 2023-07-24 2023-07-22 2023-07-17 2023-07-16 2023-07-09 2023-07-08

edit


トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2013-03-29 (金) 01:10:48