-
Notifications
You must be signed in to change notification settings - Fork 0
/
CONNECT.sql
138 lines (107 loc) · 2.87 KB
/
CONNECT.sql
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*
This file contains examples about the CONNECT storage engine.
Please copy the data files in the proper directories and adjust the paths.
Then, you can paste the snippets into your favourite MariaDB client and see the results.
CONNECT documentation:
https://mariadb.com/kb/en/connect/
*/
INSTALL SONAME 'ha_connect';
SELECT * FROM information_schema.ENGINES
WHERE ENGINE = 'CONNECT' \G
CREATE DATABASE IF NOT EXISTS maria10_snippets;
USE maria10_snippets;
CREATE OR REPLACE TABLE book_xml
(
ISBN CHAR(15) NOT NULL field_format='@',
author VARCHAR(50),
title VARCHAR(100),
pbl_year CHAR(4)
)
ENGINE = CONNECT
CHARACTER SET 'utf8'
TABLE_TYPE = XML
FILE_NAME = 'C:\\Program Files\\MariaDB 10.0\\data\\test\\books.xml'
READONLY = 1
OPTION_LIST = 'EXPAND=1,MULNODE=author,LIMIT=2';
SELECT * FROM book_xml \G
CREATE OR REPLACE TABLE book_csv
(
ISBN CHAR(15) NOT NULL,
author VARCHAR(50) NOT NULL,
title VARCHAR(100) NOT NULL,
pbl_year VARCHAR(4) NOT NULL
)
ENGINE = CONNECT
CHARACTER SET 'utf8'
TABLE_TYPE = CSV
FILE_NAME = 'C:\\Program Files\\MariaDB 10.0\\data\\test\\books.csv'
READONLY = 1
HEADER = 1
SEP_CHAR = ','
QCHAR = '"'
ENDING = 1;
SELECT * FROM book_csv \G
CREATE OR REPLACE TABLE book_author
(
title char(50) NOT NULL,
author char(50) DEFAULT NULL FLAG=2
)
ENGINE = CONNECT
TABLE_TYPE = XCOL
TABNAME = 'book_csv'
OPTION_LIST = 'colname=author';
SELECT * FROM book_author;
CREATE OR REPLACE TABLE book
(
ISBN CHAR(15) NOT NULL,
author VARCHAR(50) NOT NULL,
title VARCHAR(100) NOT NULL,
pbl_year VARCHAR(4) NOT NULL
)
ENGINE = InnoDB;
INSERT INTO book (ISBN, author, title, pbl_year)
VALUES ('9782840825685', 'Edgar Lee Masters', 'Spoon River Anthology', '');
CREATE OR REPLACE TABLE book_proxy
ENGINE = CONNECT
TABLE_TYPE = PROXY
TABNAME = book
OPTION_LIST = 'user=root,password=proot';
SELECT * FROM book_proxy;
CREATE OR REPLACE TABLE book_tbl
ENGINE = CONNECT
TABLE_TYPE = TBL
TABLE_LIST = 'book_xml,book_csv,book_proxy'
OPTION_LIST = 'user=root,password=proot';
SELECT * FROM book_tbl;
CREATE OR REPLACE TABLE users_dir
(
drive char(2) NOT NULL,
path varchar(256) NOT NULL,
file_name varchar(256) NOT NULL,
file_type char(4) NOT NULL,
size double(12,0) NOT NULL FLAG=5,
full_name VARCHAR(262) AS (CONCAT(drive, path, file_name, file_type)),
last_modified datetime NOT NULL
)
ENGINE = CONNECT
TABLE_TYPE = DIR
FILE_NAME = 'c:\\Users\\*.*';
SELECT * FROM users_dir \G
CREATE OR REPLACE TABLE show_master_status
ENGINE = CONNECT
TABLE_TYPE = MYSQL
SRCDEF = 'SHOW MASTER STATUS'
CONNECTION = 'srv_local';
-- only Windows
CREATE OR REPLACE TABLE mac_addr
(
host VARCHAR(132) NOT NULL FLAG=1,
card VARCHAR(132) NOT NULL NOT NULL FLAG=11,
addr CHAR(24) NOT NULL FLAG=12,
ip CHAR(16) NOT NULL FLAG=15,
gateway CHAR(16) NOT NULL FLAG=17,
lease DATETIME NOT NULL FLAG=23
)
ENGINE = CONNECT
TABLE_TYPE = MAC;
SELECT * FROM mac_addr;