2014年10月16日 星期四

[LTU]1016資料庫系統employee table

create table employee(
fname char(20) not null,
minit char(20) not null,
lname char(20) not null,
ssn int(10) not null primary key,
bdate date,
address varchar(50),
sex char(2) not null,
salary int(10) not null,
super_ssn int(10),
dno char(2));

insert into employee values
('John','B','Smith',123456789,'1965-01-09','731 Fondren Houston TX','M',30000,333445555,'5'),
('Franklin','T','Wong',333445555,'1955-12-08','638 Voss Houston TX','M',40000,888665555,'5'),
('Alicia','J','Zelaya',999887777,'1968-01-19','3321 Castle Spring TX','F',25000,987654321,'4'),
('Jennifer','S','Wallace',987654321,'1941-06-20','291 Berry Bellaire TX','F',43000,888665555,'4'),
('Ramesh','K','Narayan',666884444,'1962-09-15','975 Fire Oak Humble TX','M',38000,333445555,'5'),
('Joyce','A','English',463463463,'1972-07-31','5631 Rice Houston TX','F',25000,333445555,'5'),
('Ahmad','V','Jabbar',987987987,'1969-03-29','980 Dallas Houston TX','M',25000,987654321,'4'),
('James','E','Borg',888665555,'1937-11-10','450 Stone Houston TX','M',55000,NULL,'1'),
('Josh','B','Bush',234516789,'1963-10-28','722 Fondren Houston TX','F',35000,998765432,'1');


2014年10月9日 星期四

[LTU]1008資料庫系統test1

1.擷取所有主修'CS'的大四學生
mysql> select Name from STUDENT where Major='CS';
+-------+
| Name  |
+-------+
| Smith |
| Brown |
+-------+
2 rows in set (0.00 sec)


2.擷取所有在2007及2008年由King教授所開得課程名稱
mysql> select Course_name from COURSE,SECTION where COURSE.Course_number=SECTION.Course_number and Instructor='King' and Year between '07' and '08';
+----------------------+
| Course_name          |
+----------------------+
| Discrete Mathematics |
+----------------------+
1 row in set (0.02 sec)


3.對每一學期由king教授所開得課程擷取其課程編號, 學期(semester), 學年及修課的學生人數
mysql> select Course_number,Semester,Year,count(Student_number) as count from SECTION,GRADE_REPORT where SECTION.Section_identifier=GRADE_REPORT.Section_identifier and Instructor='King';
+---------------+----------+------+-------+
| Course_number | Semester | Year | count |
+---------------+----------+------+-------+
| MATH2410      | Fall     | 07   |     1 |
+---------------+----------+------+-------+
1 row in set (0.01 sec)

[LTU]1009資料庫系統5個table

create table STUDENT(
Name varchar(10),
Student_number int(3),
Class int(2),
Major varchar(20));

insert into STUDENT values('Smith',17,1,'CS'),('Brown',8,2,'CS');

create table COURSE(
Course_name varchar(50),
Course_number varchar(10),
Credit_hours int(3),
Department varchar(20));

insert into COURSE values('Intro to Computer Science','CS1310',4,'CS'),('Data Structures','CS3320',4,'CS'),('Discrete Mathematics','MATH2410',3,'MATH'),('Database','CS3380',3,'CS');

create table SECTION(
Section_identifier int(3),
Course_number varchar(10),
Semester varchar(10),
Year varchar(2),
Instructor varchar(20));

insert into SECTION values(85,'MATH2410','Fall','07','King'),(92,'CS1310','Fall','07','Anderson'),(102,'CS3320','Spring','08','Knuth'),(112,'Math2410','Fall','08','Chang'),(119,'CS1310','Fall','08','Anderson'),(135,'CS3380','Fall','08','Stone');

create table GRADE_REPORT(
Student_number int(3),
Section_identifier int(3),
Grade varchar(1));

insert into GRADE_REPORT values(17,112,'B'),(17,119,'C'),(8,85,'A'),(8,92,'A'),(8,102,'B'),(8,135,'A');

create table PREREQUISITE(
Course_number varchar(10),
Prerequisite_number varchar(10));

insert into PREREQUISITE values('CS3380','CS3320'),('CS3380','MATH2410'),('CS3320','CS1310');

2014年8月12日 星期二

[HTML]使用 Veiwport 設定手機網頁的螢幕解析度

<meta name="viewport" content="width=device-width; initial-scale=1.0;">


Viewport 其他屬性
width設定畫面寬度
height設定畫面高度
initial-scale設定畫面的初始縮放比例
minimum-scale設定畫面的最小縮放比例
maximum-scale設定畫面的最大縮放比例
user-scalable設定是否允許使用者改變縮放比例

根據W3C草案,在meta tag中viewport有以下屬性可設定

  • width:[數字] 或 device-width
  • height:[數字] 或 device-height
  • initial-scale:最小0.25,最大5
  • minimum-scale:最小0.25,最大5
  • maximum-scale:最小0.25,最大5
  • user-scalable:1 或 0 (yes 或 no)


[HTML]送出表單前跳出確認對話框

<input type="submit" value="送出" onclick="return confirm('確定送出?\n送出後不可修改')"/>

2014年7月15日 星期二

[HTML]框線、格線運用


表格標籤 <TABLE> 的屬性有 BORDER, FRAME, HEIGHT, WIDTH, CELLSPACING, CELLPADDING, ALIGN, 及 RULES 等. 其說明如下:

  • BORDER=0,1,... --- 控制表格外框的寬度. 不加參數 BORDER 與 BORDER=0 同義, 均表示表格沒有畫格子. 參數 BORDER 與 BORDER=1 同義.
  • FRAME=arg --- 控制表格外框四個邊的顯現與否, 其中 arg 可為 :
    • void --- 隱藏表格外框
    • above --- 僅出現上框
    • below --- 僅出現下框
    • hsides --- 僅出現上下兩框
    • vsides --- 僅出現左右兩框
    • box --- 出現表格外框四個邊
    • border --- 出現表格外框四個邊
  • HEIGHT=70% --- 控制表格在整個視窗中所占高的比率, 亦可以 pt, in(英尺), cm 等表示.
  • WIDTH=80% --- 控制表格在整個視窗中所占寬的比率, 亦可以 pt, in(英尺), cm 等表示.
  • CELLSPACING=1, 2, ... --- 控制欄位與欄位之間的寬度
  • CELLPADDING=1, 2, ... --- 控制欄位與資料之間的寬度
  • ALIGN=left, right --- 表格左或右會有字串出現
  • RULES=arg --- 控制表格橫線及直線等. 其中 arg 可為 :
    • none --- 隱藏分格線
    • rows --- 僅出現橫線
    • cols --- 僅出現垂直線
    • all --- 與不加參數 RULES 相同, 會畫出所有分格線
    • 其他如 groups

2014年6月17日 星期二

資料庫系統導論筆記備份

1.直接照表格的打就出來了    要先登入學號的那個帳號
select now(), user(), database();

2.先創一個學號的資料庫 在轉到 學號的底下
create database 998G104;
use 998G104;

打出一個要求表格
create table std_info (
no int(3) not null extra auto_increment,
std_id varchar(15) not null,
name varchar(15) not null,
gender enum('M','F') not null ,
primary key (no)
);

3.把資料打入表格內部
insert into std_into values(1,'998j001','Mary Chen','F'),(2,'998j002','Joe Lin','M'),(3,'998j003','Jason Tang','M');

select no,std_id,name,gender from std_into;  在資料夾std_into只顯示no,std_id,name,gender的資料

4.在表格中加入place把他加入到 name底下
alter table std_into add place varchar(15) not null after name;

5.從檔案中把資料匯進檔案
mysql -u root -p 998G104<XXX.sql

6.匯入資料
load data local infile 'c:/XXX.txt' into table XXX.sql fields terminated by ',' ;



期末

1.

create database 998G020; 

grant all privileges on 998g020.* to '998g020'@'localhost' identified by '1234';

quit

mysql -u 998G020 -p

grant all on 998G020.* to '998G020'@'localhost' identified by '1234';

use 998g020

select now(), user(), database();


2.

create table price_table(
supplyid char(10) not null,
productid char(10) not null,
price int(4) not null,
primary key (supplyid,productid),
key productid (productid)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

create table supply_table(
supplyid char(10) not null,
supplier varchar(30) not null,
contact varchar(30) not null,
areaid char(10) not nll,
primary key (suplyid,areaid),
key 

cd c:\wamp\bin\mysql\mysql5.5.24\bin
mysql -u root -p test<mid.sql

mysql -u root -p test<std1.sql

mysql -u root -p test<test2.sql

mysql -u root -p

use test

load data local infile 'c:/data.txt' into table test fields terminated by ',' ;

delete from test where c_score = 0;



create database 998G020; //新增資料庫
drop database 998G020; //刪除資料庫
show databases; //顯示資料庫
grant all privileges on test.* to 'test'@'%' identified by '123'; //創帳號
grant select,insert,update on 998G020.* to 'test'@'%' identified by '123'; //修改權限
mysql -u user -p -h ip   //遠端登入
show grants for current_user();  //查看目前登入帳號之權限
 
10/19
create table name(
bid int(10) not null primary key,
title varchar(30) not null,
auther char(30) not null,
publish_slate datetime default '0000-00-00',
gender enum('F','M')
);
 
(quit)mysql -u root -p 資料表名稱<檔案名稱 //匯入資料表 
drop table name; //刪除資料表
show tables; //顯示資料表
use name //使用資料表
desc name; //資料表內容
 
10/27
alter table tbname add newfield datatype after ‘field’;  //新增欄位
alter table tbname change oldfield newfield datatype; //修改欄位
alter table tbname drop oldfield ; //整欄刪除

Alter table test change stdname new_s_name varchar(20) not null;

11/2
create table students(
sid int(10) not null,
name varchar(5) not null,
birthday date,
GPA int(2),
tel int(10),
primary key(sid));

create table Std_Address(
sid int(10) not null primary key,
address char(100));

insert into students 
values
(99800001,'Calvin Chen','1990-01-01',5,'02-1234-5678'),
(99800002,'Calvin Lin','1990-12-01',9,'03-1234-5678'),
(99800003,'Calvin Chang','1990-10-01',7,'04-1234-5678');

select * from students; //顯示資料表欄位內容

delete from students; //字面上意思

load data local infile '路徑' into table students fields terminated by ',';
/*
筆記本內容
99800004,Calvin Lee,1990-11-01,9,05-1234-5678
99800005,Calvin Wen,1993-11-01,2,06-1234-5678
*/

alter table Std_Address add foreign key (sid) references students (sid);
 //students為Std_Address父類別
 
11/23
 
create table t1(
code char(5),
title varchar(10),
pirce int(5)
);

insert into t1 values
('P657','C',490),
('P659','ASP',600),
('L333','PHP',580);
alter table t1 add place varchar(30); //新增欄位
update tbname set dataname='data' where dataname='data';  //修改欄位內容 where 條件

11/30

mysql -H -e "select * from test.std" -p > test.htm
mysql -X -e "select * from test.std" -p 

12/7
select * from inst where eid between 'e001' and 'e003'; //搜尋table(inst) eid e001~e003
select * from inst where eid not between 'e001' and 'e003';
select * from inst where eid in ('e001','e003');
create table new_table select * from old_table;
elect * from test union select * from testbak; //聯集

insert into testbak values('998g004','Jeremy','Lin','m','Yuan-Lin',56,48,52); //交集

select distinct test.* from test,testbak where test.std_id not in (select testbak.std_id from testbak); //差集test為主

select * , (c_score+e_score+m_score)/3 as average from testbak order by average desc; //計算c,e,m平均、排序


12/14
mysql> select gender, avg(c_score),avg(e_score),avg(m_score),count(*) from test group by gender='m';
+--------+--------------+--------------+--------------+----------+
| gender | avg(c_score) | avg(e_score) | avg(m_score) | count(*) |
+--------+--------------+--------------+--------------+----------+
| f      |      70.0000 |      64.0000 |      69.0000 |        2 |
| m      |      64.8000 |      75.4000 |      64.8000 |        5 |
+--------+--------------+--------------+--------------+----------+

mysql> select count(*),avg(c_score),avg(e_score),avg(m_score) from test where std_id in('998g001','998g002','998g004','998g007');
+----------+--------------+--------------+--------------+
| count(*) | avg(c_score) | avg(e_score) | avg(m_score) |
+----------+--------------+--------------+--------------+
|        4 |      61.5000 |      67.7500 |      68.2500 |
+----------+--------------+--------------+--------------+

mysql> select inst.*, std.* from std left outer join inst on inst.city=std.city;
+------+-----------------+----------+---------------------+------------+------+----------------+-----+----------+
| eid  | name            | city     | rank                | department | sid  | name           | gpa | city     |
+------+-----------------+----------+---------------------+------------+------+----------------+-----+----------+
| E001 | Lee,Ann         | Taipei   | Professor           | CS         | s001 | Chen,Huei-Ann  | 3.7 | Taipei   |
| E002 | Yang,Jing-Thurm | Tao-Yuan | Associate Professor | CIS        | s002 | Jang,Hsiao-Yu  |   3 | Tao-Yuan |
| E003 | Lee,Hong-Jhang  | Taichung | Assistant Professor | MATH       | s003 | Chang,San-Fung | 3.2 | Taichung |
| NULL | NULL            | NULL     | NULL                | NULL       | s004 | Lee,Se-Fang    | 2.9 | Tainan   |
+------+-----------------+----------+---------------------+------------+------+----------------+-----+----------+


mysql> select inst.*, std.* from std right outer join inst on inst.city=std.city;
+------+-----------------+----------+---------------------+------------+------+----------------+------+----------+
| eid  | name            | city     | rank                | department | sid  | name           | gpa  | city     |
+------+-----------------+----------+---------------------+------------+------+----------------+------+----------+
| E001 | Lee,Ann         | Taipei   | Professor           | CS         | s001 | Chen,Huei-Ann  |  3.7 | Taipei   |
| E002 | Yang,Jing-Thurm | Tao-Yuan | Associate Professor | CIS        | s002 | Jang,Hsiao-Yu  |    3 | Tao-Yuan |
| E003 | Lee,Hong-Jhang  | Taichung | Assistant Professor | MATH       | s003 | Chang,San-Fung |  3.2 | Taichung |
| E004 | Kobe Brian      | Kellung  | Lecturer            | PHYS       | NULL | NULL           | NULL | NULL     |
+------+-----------------+----------+---------------------+------------+------+----------------+------+----------+


 creat view viewname as select * test; //create view...

12/21
delimiter % //修改結束符號

create procedure pro1()
begin
select * from test where last_name = 'Lin';
end %

call pro1%

create procedure pro2(a varchar(15))
begin
select * from test where last_name =a;
end % 

select note_text,match (note_text) against('rabbit') as rank from testfull%

create procedure pro3(tmp varchar(20))
begin
select * from testfull where match(note_text) against(tmp);
end % 

call pro3('food')%

show procedure status;
drop procedure pro1;
 

102/1/4
create table test(std_id char(15) not null,
first_name varchar(15) not null,
last_name varchar(15) not null,
gender enum('m','f') not null,
place varchar(30) not null,
c_score tinyint(3) not null,
e_score tinyint(3) not null,
m_score tinyint(3) not null,
primary key (std_id),
fulltext(std_id,first_name,last_name,place))engine=MYISAM;
 select * from test where match (std_id,first_name,last_name,place) against ('Paul'); 索引Paul
要是忘了在表格裡打fulltext 可以在程式理打
alter table tbname ENGINE=MYISAM;
alter table tbname add fulltext(std_id,first_name,last_name,place);

嶺東資科系四年課程

022
2014-02-01 ~ 2014-07-31
課程編號標題老師學分班級
80027170S701羽球 1共同
8G4D0098G042影像處理 3資科日四技4B
8G409998G042週班會 0資科日四技4B
MG18001MG011分散式系統 3資科碩士班1A
80028460S908職涯發展典範 2共同
021
2013-08-01 ~ 2014-01-31
課程編號標題老師學分班級
8G4C0018G042實務專題 3資科日四技4B
MG18011MG011資料倉儲理論與實務 3資科碩士班1A
8G4D0118G042人工智慧 3資科日四技4B
8G409998G042週班會 0資科日四技4B
VG28002VG021平行演算法 3資科碩士在職2A
8C4D0058C042資訊管理實習(一) 3資管日四技4B
80028520S935經典流行音樂賞析 2共同
012
2013-02-01 ~ 2013-07-31
課程編號標題老師學分班級
8G3D0198G032RFID資訊系統 3資科日四技3B
8G3D0118G032物件導向系統分析 3資科日四技3B
8G3D0078G032網站與資料庫應用 3資科日四技3B
8G3D0068G032資訊安全 3資科日四技3B
8G3C0018G032Web組件設計與開發 3資科日四技3B
8G309998G032週班會 0資科日四技3B
80028080S908鋼琴中的美感世界 2共同
011
2012-08-01 ~ 2013-01-31
課程編號標題老師學分班級
8G309998G032週班會 0資科日四技3B
8G3D0178G032RFID概論 3資科日四技3B
8G3D0168G032智慧型行動裝置軟體設計 3資科日四技3B
8G3D0048G032作業系統 3資科日四技3B
8G3C0038G032通訊原理 3資科日四技3B
8G3C0028G032資料庫系統導論 3資科日四技3B
80028190S901中國音樂鑑賞 2共同
002
2012-02-01 ~ 2012-07-31
課程編號標題老師學分班級
8G2C0158G022離散數學 3資科日四技2B
8G2C0148G022機率與統計 3資科日四技2B
8G2C0128G022數位邏輯 3資科日四技2B
8G2C0088G022訊號與系統 3資科日四技2B
8G2C0068G022數位邏輯實習 2資科日四技2B
8G2C0048G022延伸標記語言 2資科日四技2B
8G2A0148G022公民素養 2資科日四技2B
8G209998G022週班會 0資科日四技2B
80027290S729健康休閒與生活二 1共同
8G2D0078G022物件導向程式證照輔導 2資科日四技2B
001
2011-08-01 ~ 2012-01-31
課程編號標題老師學分班級
8G2C0038G022工程數學 3資科日四技2B
8G2A0068G022生涯、群己與人倫 2資科日四技2B
8G209998G022週班會 0資科日四技2B
80040010S801軍訓 2共同
80027180S718健康休閒與生活一 2共同
8G2C0118G022電子電路 3資科日四技2B
8G2C0188G022線性代數 3資科日四技2B
8G2C0158G022網路技術概論 3資科日四技2B
8G2C0128G022電子電路實習 2資科日四技2B
8G2C0108G022資料結構 3資科日四技2B
992
2011-01-23 ~ 2011-07-31
課程編號標題老師學分班級
8G112168G012網頁程式設計 3資科日四技1B
8G111008G012體育 2資科日四技1B
8G111178G012物件導向程式設計 3資科日四技1B
8G111278G012電腦動畫 3資科日四技1B
8G116008G012微積分 3資科日四技1B
8G116028G012資訊法規與倫理 2資科日四技1B
8G117178G012本國語文(二) 2資科日四技1B
8G117228G012資訊科技與生活(二) 2資科日四技1B
8G117268G012外國語文能力訓練(二) 2資科日四技1B
991
2010-08-01 ~ 2011-01-22
課程編號標題老師學分班級
8G116008G012微積分 3資科日四技1B
8G111778G012Linux管理實務 3資科日四技1B
8G111768G012計算機程式設計 3資科日四技1B
8G111008G012體育 2資科日四技1B
8G117258G012外國語文能力訓練(一) 2資科日四技1B
8G117198G012資訊科技與生活(一) 2資科日四技1B
8G117168G012本國語文(一) 2資科日四技1B
8G116018G012計算機概論 3資科日四技1B
不分學期的課程
課程編號標題老師學分班級
10211024001TQC技能檢定相關資訊 0lms01
980002智財產知識大挑戰 1lms01