這個練習跟以下的練習有關 http://www.mysql.tw/2013/04/blog-post.html 這個練習資料庫的建立,以及簡單的用PHP來連結資料庫,然後做資料新增與顯示。 http://www.mysql.tw/2013/04/blog-post_18.html 這個練習直接使用SQL指令的SELECT來篩選需要的資料。 以下是練習的步驟: (1) 為了後續的練習,我們必須先加上有意義的資料到資料表中,所以先把舊資料刪除了。 假設你的資料庫是newdb //使用newdbname資料庫 ~ 紅色請依實際狀況修改 use newdbname ; //顯示裡面有哪些資料表 show tables; //刪除舊的資料 delete from customer; delete from order_body; delete from order_head; delete from product; //插入有意義的資料 ~ customer insert into customer(cus_id, cus_name, cus_address, cus_no) values (1, '…
SQL指令包含四大類型 : DDL (資料定義語言)、DML (資料處理語言)、DCL (資料控制語言)、TCL (交易控制語言)。 DDL ( Data Definition Language ) 資料定義語言 CREATE - to create objects in the database ALTER - alters the structure of the database DROP - delete objects from the database TRUNCATE - remove all records from a table, including all spaces allocated for the records are removed RENAME - rename an object 範例: CREATE DATABASE [database name] CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE TABLE [table name] ( fid MEDIUMINT NOT NULL AUTO_INCREMENT, fname varchar(20),…