Top > VisualBasicあれこれ > MySQLデータベースの構築


Everything is expanded.Everything is shortened.
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
-
|
|
|
!
 
 
-
|
|
|
!
 
 
-
|
|
|
|
|
|
|
!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
CREATE TABLE `vbnet`.`department` (
  `id` INTEGER NOT NULL AUTO_INCREMENT,
  `name` VARCHAR(255) NOT NULL,
  PRIMARY KEY (`id`)
)
ENGINE = InnoDB;
 
CREATE TABLE `vbnet`.`address` (
  `id` INTEGER NOT NULL AUTO_INCREMENT,
  `name` VARCHAR(255) NOT NULL,
  PRIMARY KEY (`id`)
)
ENGINE = InnoDB;
 
CREATE TABLE `vbnet`.`employee` (
  `id` INTEGER NOT NULL AUTO_INCREMENT,
  name varchar(255) not null,
  job_type varchar(30) not null,
  salary integer,
  department_id integer,
  address_id integer,
  PRIMARY KEY (`id`)
)
ENGINE = InnoDB;
 
ALTER TABLE `vbnet`.`employee` ADD CONSTRAINT `fk_department` FOREIGN KEY `fk_department` (`department_id`)
    REFERENCES `department` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION;
 
ALTER TABLE `vbnet`.`employee` ADD CONSTRAINT `fk_address` FOREIGN KEY `fk_address` (`address_id`)
    REFERENCES `address` (`id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION;
 
INSERT INTO DEPARTMENT VALUES(1,'ACCOUNTING');
INSERT INTO DEPARTMENT VALUES(2,'RESEARCH');
INSERT INTO DEPARTMENT VALUES(3,'SALES');
INSERT INTO DEPARTMENT VALUES(4,'OPERATIONS');
 
INSERT INTO ADDRESS VALUES(1,'STREET 1');
INSERT INTO ADDRESS VALUES(2,'STREET 2');
INSERT INTO ADDRESS VALUES(3,'STREET 3');
INSERT INTO ADDRESS VALUES(4,'STREET 4');
INSERT INTO ADDRESS VALUES(5,'STREET 5');
INSERT INTO ADDRESS VALUES(6,'STREET 6');
INSERT INTO ADDRESS VALUES(7,'STREET 7');
INSERT INTO ADDRESS VALUES(8,'STREET 8');
INSERT INTO ADDRESS VALUES(9,'STREET 9');
INSERT INTO ADDRESS VALUES(10,'STREET 10');
INSERT INTO ADDRESS VALUES(11,'STREET 11');
INSERT INTO ADDRESS VALUES(12,'STREET 12');
INSERT INTO ADDRESS VALUES(13,'STREET 13');
INSERT INTO ADDRESS VALUES(14,'STREET 14');
 
INSERT INTO EMPLOYEE VALUES(1,'ALLEN','SALESMAN',1600,3,1);
INSERT INTO EMPLOYEE VALUES(2,'WARD','SALESMAN',1250,3,2);
INSERT INTO EMPLOYEE VALUES(3,'JONES','MANAGER',2975,2,3);
INSERT INTO EMPLOYEE VALUES(4,'MARTIN','SALESMAN',1250,3,4);
INSERT INTO EMPLOYEE VALUES(5,'BLAKE','MANAGER',2850,3,5);
INSERT INTO EMPLOYEE VALUES(6,'CLARK','MANAGER',2450,1,6);
INSERT INTO EMPLOYEE VALUES(7,'SCOTT','ANALYST',3000.0,2,7);
INSERT INTO EMPLOYEE VALUES(8,'KING','PRESIDENT',5000,1,8);
INSERT INTO EMPLOYEE VALUES(9,'TURNER','SALESMAN',1500,3,9);
INSERT INTO EMPLOYEE VALUES(10,'ADAMS','CLERK',1100,2,10);
INSERT INTO EMPLOYEE VALUES(11,'JAMES','CLERK',950,3,11);
INSERT INTO EMPLOYEE VALUES(12,'FORD','ANALYST',3000,2,12);
INSERT INTO EMPLOYEE VALUES(13,'MILLER','CLERK',1300,1,13);
INSERT INTO EMPLOYEE VALUES(14,'SMITH','CLERK',800,2,14);

リロード   新規 編集 凍結 差分 添付 複製 名前変更   ホーム 一覧 単語検索 最終更新 バックアップ リンク元   ヘルプ   最終更新のRSS
Last-modified: 2012-08-08 (水) 23:26:22 (2928d)