-
Notifications
You must be signed in to change notification settings - Fork 1
/
MySQL個別のネタ.txt
48 lines (39 loc) · 2.95 KB
/
MySQL個別のネタ.txt
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
------------------------------------------------------------
■バルクインサート
\bulk_insert_1.sql
\bulk_insert_2.sql
------------------------------------------------------------
■REPLACE文
DROP TABLE emp;
CREATE TABLE emp (empno NUMERIC(4) ,
ename VARCHAR(10),
job VARCHAR(9),
mgr NUMERIC(4),
hiredate DATE,
sal NUMERIC(7,2),
comm NUMERIC(7,2),
deptno NUMERIC(2),
primary key(empno) );
INSERT INTO emp VALUES (7369,'SMITH','CLERK',7902,str_to_date('17-12-1980','%d-%m-%Y'),800,null,20);
INSERT INTO emp VALUES (7499,'ALLEN','SALESMAN',7698,str_to_date('20-02-1981','%d-%m-%Y'),1600,300,30);
INSERT INTO emp VALUES (7521,'WARD','SALESMAN',7698,str_to_date('22-02-1981','%d-%m-%Y'),1250,500,30);
INSERT INTO emp VALUES (7566,'JONES','MANAGER',7839,str_to_date('02-04-1981','%d-%m-%Y'),2975,null,20);
INSERT INTO emp VALUES (7654,'MARTIN','SALESMAN',7698,str_to_date('28-09-1981','%d-%m-%Y'),1250,1400,30);
INSERT INTO emp VALUES (7698,'BLAKE','MANAGER',7839,str_to_date('01-05-1981','%d-%m-%Y'),2850,null,30);
INSERT INTO emp VALUES (7782,'CLARK','MANAGER',7839,str_to_date('09-06-1981','%d-%m-%Y'),2450,null,10);
INSERT INTO emp VALUES (7788,'SCOTT','ANALYST',7566,str_to_date('09-12-1982','%d-%m-%Y'),3000,null,20);
INSERT INTO emp VALUES (7839,'KING','PRESIDENT',null,str_to_date('17-11-1981','%d-%m-%Y'),5000,null,10);
INSERT INTO emp VALUES (7844,'TURNER','SALESMAN',7698,str_to_date('08-09-1981','%d-%m-%Y'),1500,0,30);
INSERT INTO emp VALUES (7876,'ADAMS','CLERK',7788,str_to_date('12-01-1983','%d-%m-%Y'),1100,null,20);
INSERT INTO emp VALUES (7900,'JAMES','CLERK',7698,str_to_date('03-12-1981','%d-%m-%Y'),950,null,30);
INSERT INTO emp VALUES (7902,'FORD','ANALYST',7566,str_to_date('03-12-1981','%d-%m-%Y'),3000,null,20);
INSERT INTO emp VALUES (7934,'MILLER','CLERK',7782,str_to_date('23-01-1982','%d-%m-%Y'),1300,null,10);
SELECT * FROM emp;
REPLACE INTO emp VALUES(7369,'SMITH','CLERK',7902,str_to_date('17-12-1980','%d-%m-%Y'),800,null,40);
REPLACE INTO emp VALUES (7654,'MARTIN','SALESMAN',7698,str_to_date('28-09-1981','%d-%m-%Y'),1250,1400,40);
REPLACE INTO emp VALUES (7902,'FORD','ANALYST',7566,str_to_date('03-12-1981','%d-%m-%Y'),3000,null,40);
REPLACE INTO emp VALUES (8000,'MySQL','DBA',7839,str_to_date('13-07-2014','%d-%m-%Y'),9000,null,40);
REPLACE INTO emp VALUES (8001,'PostgreSQL','DBA',7839,str_to_date('13-07-2014','%d-%m-%Y'),9000,null,40);
SELECT * FROM emp;
REPLACE INTO emp VALUES(7369,'SMITH','CLERK',7902,str_to_date('17-12-1980','%d-%m-%Y'),800,null,40),(7654,'MARTIN','SALESMAN',7698,str_to_date('28-09-1981','%d-%m-%Y'),1250,1400,40),(7902,'FORD','ANALYST',7566,str_to_date('03-12-1981','%d-%m-%Y'),3000,null,40),(8000,'MySQL','DBA',7839,str_to_date('13-07-2014','%d-%m-%Y'),9000,null,40),(8001,'PostgreSQL','DBA',7839,str_to_date('13-07-2014','%d-%m-%Y'),9000,null,40);
------------------------------------------------------------