SQL Lesson 0SQL Lesson 0
Database 應用例:
全球各國 COVID-19 排名前15確診人數https://public.flourish.studio/visualisation/1488517/embed
DROP DATABASE IF EXISTS vovid2; CREATE DATABASE IF NOT EXISTS vovid2 CHARACTER SET utf8; USE vovid2; CREATE TABLE `countries` ( `id` varchar(50) COLLATE utf8_bin NOT NULL, `name` varchar(255) COLLATE utf8_bin NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; INSERT INTO `countries` (`id`, `name`) VALUES ('001', 'TAIWAN'), ('002', 'USA'), ('003', '日本'), ('004', '新加坡'), ('005', '英國');
請執行下列 SQL 程式
-- DB SQL Lesson 0phpMyAdmin SQL Dump USE test2; -- 資料庫: `test2` CREATE TABLE `countries` ( `id` varchar(50) COLLATE utf8_bin NOT NULL, `name` varchar(255) COLLATE utf8_bin NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; INSERT INTO `countries` (`id`, `name`) VALUES ('001', 'TAIWAN'), ('002', 'USA'), ('003', '日本'), ('004', '新加坡'), ('005', '英國'); CREATE TABLE `orders` ( `orderno` int(11) NOT NULL, `orderdate` date NOT NULL, `countryid` varchar(50) COLLATE utf8_bin NOT NULL, `firstname` varchar(50) COLLATE utf8_bin NOT NULL, `lastname` varchar(50) COLLATE utf8_bin NOT NULL, `ordervalue` int(11) NOT NULL, PRIMARY KEY (`orderno`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; INSERT INTO `orders` (`orderno`, `orderdate`, `countryid`, `firstname`, `lastname`, `ordervalue`) VALUES (1, '2010-10-09', '001', 'John', 'Who', 10000), (2, '2010-10-10', '002', 'John', 'Williams', 50000), (3, '2010-12-01', '005', 'John', 'Smith', 95000), (4, '2011-01-01', '002', 'Mary', 'White', 5000);
|