AP102 2016/06/01 資料庫

AP102 2016/06/01 資料庫


資料庫

大型資料庫 攜帶不便 效率較好
資料庫合在一起管理

小型資料庫 攜帶方便 效率較差
一個檔案作為一個資料庫

一開始只會有欄,沒有列

SQlite 沒有欄位,有設跟沒設一樣

索引

 主鍵(primary key):
一個資料的主索引,資料皆不可重複

例如:身分證字號

 唯一鍵(unique key):
限制這個欄位的資料不可以重複

例如:電話號碼

 一般索引(index):單純設置索引

<?php
    //$db=new pdo("mysql:host=資料庫位址",資料庫帳號,資料庫密碼);
    $db=new pdo("mysql:host=localhost:8889","root","root");
    $db->query("set names 'utf8' ");
    $db->query("use databasetest");// use 資料庫名稱
    $db->query("insert into test (title,url,description) 
    values('This is title ','www.google.org.tw/','ucc'),('aaa','bbb','cccc')");


` 括起來可使用保留字當作自定義名稱

$db->prepare("insert into `insert` (title,url,description) 
        values(?,?,?)")->execute($_POST);


delete from 資料表名稱 where 篩選條件

        $db->query("delete from test where `id` = '8'");

Comments

Popular posts from this blog

MEGA 暫存檔案刪除

IOS GCD多執行緒

利用CMD指令強制刪除