mysql 学习记录---->索引、视图

来源:互联网 发布:田岛美工刀架 编辑:程序博客网 时间:2024/06/05 05:32
一   理论:
1) 设计索引的原则:
1.搜索的索引列是出现在where子句或者连接子句中的列。
2.使用唯一索引时,索引的列基数越大效果越好。
3.使用短索引涉及的IO更好,比较更快。在索引缓存中的块能容纳更多的键值。
4.最多前缀:即在创建一个n列的索引时,实际是创建了mysql的N个索引,可利用索引中最左边的列来匹配行。
5.过度索引可能会使mysql选择不到要使用的最好索引。
6.在innodb存储引擎的表的保存顺序是:主键、唯一索引、内部列。
2) 视图的优势:
1.简单:面对用户的是过滤完成的结果集。
2.安全:对视图的权限控制可以限制到行与列。
3.数据独立:源表增加与修改列名可与视图无影响。
 

二   sql记录:

[sql] view plaincopy
  1. 1) 使用hash与b-tree索引  
  2. mysql> use test1;  
  3. Reading table information for completion of table and column names  
  4. You can turn off this feature to get a quicker startup with -A  
  5.   
  6. Database changed  
  7.   
  8. mysql>  CREATE TABLE city_memory(  
  9.     ->   `city_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,  
  10.     ->   `city` varchar(50) NOT NULL,  
  11.     ->   `country_id` smallint(5) unsigned NOT NULL,  
  12.     ->   `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,  
  13.     ->   PRIMARY KEY (`city_id`),  
  14.     ->   KEY `idx_fk_country_id` (`country_id`),  
  15.     ->   CONSTRAINT `fk_city_country` FOREIGN KEY (`country_id`) REFERENCES `country` (`country_id`) ON UPDATE CASCADE  
  16.     -> ) ENGINE=memory AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;  
  17.   
  18. mysql> select * from city;  
  19. +---------+------+------------+---------------------+  
  20. | city_id | city | country_id | last_update         |  
  21. +---------+------+------------+---------------------+  
  22. |     251 | bill |      10000 | 2015-10-02 20:48:51 |  
  23. +---------+------+------------+---------------------+  
  24.   
  25. mysql> explain   
  26.     -> select * from city   
  27.     -> where country_id > 9 and country_id<23186  \G;  
  28. *************************** 1. row ***************************  
  29.            id: 1  
  30.   select_type: SIMPLE  
  31.         table: city  
  32.          type: range  
  33. possible_keys: idx_fk_country_id  
  34.           key: idx_fk_country_id  
  35.       key_len: 2  
  36.           ref: NULL  
  37.          rows: 1  
  38.         Extra: Using where  
  39.   
  40. ERROR:   
  41. No query specified  
  42.   
  43. mysql> insert into city_memory select * from city;  
  44.   
  45. mysql> explain  select * from city_memory  where country_id > 9 and country_id<23186\G  
  46. *************************** 1. row ***************************  
  47.            id: 1  
  48.   select_type: SIMPLE  
  49.         table: city_memory  
  50.          type: system  
  51. possible_keys: idx_fk_country_id  
  52.           keyNULL  
  53.       key_len: NULL  
  54.           ref: NULL  
  55.          rows: 1  
  56.         Extra:   
  57.   
  58. 2)使用包含join,union,group,having,count等的视图  
  59. mysql> CREATE TABLE `payment` (  
  60.     ->   `id` smallint(6) DEFAULT NULL,  
  61.     ->   `staff_id` smallint(6) DEFAULT NULL,  
  62.     ->   `amount` decimal(15,2) DEFAULT NULL,  
  63.     ->   KEY `id` (`id`)  
  64.     -> ) ENGINE=innodb AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;  
  65.   
  66. mysql> insert into payment(staff_id,amount) values  
  67.     -> (1,3.2),  
  68.     -> (1,5.8),  
  69.     -> (2,3.5),  
  70.     -> (1,9.3),  
  71.     -> (2,9.1);  
  72.   
  73. mysql> create or replace view payment_sum as  
  74.     -> select staff_id ,sum(amount) from payment group by staff_id;  
  75.   
  76. mysql> select * from payment_sum;  
  77. +----------+-------------+  
  78. | staff_id | sum(amount) |  
  79. +----------+-------------+  
  80. |        1 |       18.30 |  
  81. |        2 |       12.60 |  
  82. +----------+-------------+  
  83.   
  84. mysql> insert into payment(staff_id,amount) values   
  85.     -> (1,105.71038);  
  86.   
  87. mysql> select * from payment_sum;  
  88. +----------+-------------+  
  89. | staff_id | sum(amount) |  
  90. +----------+-------------+  
  91. |        1 |      124.01 |  
  92. |        2 |       12.60 |  
  93. +----------+-------------+  
  94.   
  95. mysql> drop view payment_sum;  
  96.   
  97. mysql> create or replace view payment_sum as  
  98.     -> select * from payment having sum(amount) > 10;  
  99.   
  100. mysql> select * from payment_sum;  
  101. +------+----------+--------+  
  102. | id   | staff_id | amount |  
  103. +------+----------+--------+  
  104. NULL |        1 |   3.20 |  
  105. +------+----------+--------+  
  106.   
  107. mysql> insert into payment_test( id,staff_id,amount)  values   
  108.     -> (1,1,3.2),  
  109.     -> (2,2,9.3),  
  110.     -> (3,1,1.83512935),  
  111.     -> (4,1,2.283915),  
  112.     -> (5,2,3.283852),  
  113.     -> (6,2,1.8);    
  114.   
  115. mysql> drop view payment_sum ;  
  116.   
  117. mysql> create or replace view payment_sum as  
  118.     -> select * from payment group by id having sum(amount) > 3;  
  119.   
  120. mysql> select * from payment_sum;  
  121. +------+----------+--------+  
  122. | id   | staff_id | amount |  
  123. +------+----------+--------+  
  124. |    1 |        1 |   3.20 |  
  125. |    2 |        2 |   9.30 |  
  126. |    5 |        2 |   3.28 |  
  127. +------+----------+--------+  
  128.   
  129. mysql> insert into payment(id,staff_id,amount) values ( 9,1,3.185), (19,1,9.91852);  
  130.   
  131. mysql> select * from payment_sum;  
  132. +------+----------+--------+  
  133. | id   | staff_id | amount |  
  134. +------+----------+--------+  
  135. |    1 |        1 |   3.20 |  
  136. |    2 |        2 |   9.30 |  
  137. |    5 |        2 |   3.28 |  
  138. |    9 |        1 |   3.19 |  
  139. |   19 |        1 |   9.92 |  
  140. +------+----------+--------+  
  141.   
  142. mysql> update payment set amount = 20.185 where id = 5;  
  143.   
  144. mysql> select * from payment_sum;  
  145. +------+----------+--------+  
  146. | id   | staff_id | amount |  
  147. +------+----------+--------+  
  148. |    1 |        1 |   3.20 |  
  149. |    2 |        2 |   9.30 |  
  150. |    5 |        2 |  20.19 |  
  151. |    9 |        1 |   3.19 |  
  152. |   19 |        1 |   9.92 |  
  153. +------+----------+--------+  
  154.   
  155. mysql> drop view payment_sum;   
  156.   
  157. mysql> CREATE TABLE `payment_test` (  
  158.     ->   `id` smallint(6) DEFAULT NULL,  
  159.     ->   `staff_id` smallint(6) DEFAULT NULL,  
  160.     ->   `amount` decimal(15,2) DEFAULT NULL,  
  161.     ->   KEY `id` (`id`)  
  162.     -> ) ENGINE=innodb AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;  

  163.   
  164. mysql> insert into payment_test( id,staff_id,amount)  values   
  165.     -> (1,1,13.2),  
  166.     -> (2,2,91.3),  
  167.     -> (3,1,13.83512935),  
  168.     -> (4,1,25.283915),  
  169.     -> (5,2,28.283852),  
  170.     -> (6,2,13.8);  
  171.   
  172. mysql> ( select * from payment )   
  173.     -> union   
  174.     -> ( select * from payment_test);  
  175. +------+----------+--------+  
  176. | id   | staff_id | amount |  
  177. +------+----------+--------+  
  178. |    1 |        1 |   3.20 |  
  179. |    2 |        2 |   9.30 |  
  180. |    3 |        1 |   1.84 |  
  181. |    4 |        1 |   2.28 |  
  182. |    5 |        2 |  20.19 |  
  183. |    6 |        2 |   1.80 |  
  184. |    9 |        1 |   3.19 |  
  185. |   19 |        1 |   9.92 |  
  186. |    1 |        1 |  13.20 |  
  187. |    2 |        2 |  91.30 |  
  188. |    3 |        1 |  13.84 |  
  189. |    4 |        1 |  25.28 |  
  190. |    5 |        2 |  28.28 |  
  191. |    6 |        2 |  13.80 |  
  192. +------+----------+--------+  
  193.   
  194. mysql> create or replace view payment_sum as  
  195.     -> ( select * from payment )   
  196.     -> union   
  197.     -> ( select * from payment_test)   
  198.     -> ;    
  199.   
  200. mysql> select * from payment_sum;  
  201. +------+----------+--------+  
  202. | id   | staff_id | amount |  
  203. +------+----------+--------+  
  204. |    1 |        1 |   3.20 |  
  205. |    2 |        2 |   9.30 |  
  206. |    3 |        1 |   1.84 |  
  207. |    4 |        1 |   2.28 |  
  208. |    5 |        2 |  20.19 |  
  209. |    6 |        2 |   1.80 |  
  210. |    9 |        1 |   3.19 |  
  211. |   19 |        1 |   9.92 |  
  212. |    1 |        1 |  13.20 |  
  213. |    2 |        2 |  91.30 |  
  214. |    3 |        1 |  13.84 |  
  215. |    4 |        1 |  25.28 |  
  216. |    5 |        2 |  28.28 |  
  217. |    6 |        2 |  13.80 |  
  218. +------+----------+--------+  
  219.   
  220. mysql> update payment_test set amount = 113.3333  
  221.     ->  where id = 6;  
  222.   
  223. mysql> select * from payment_sum;  
  224. +------+----------+--------+  
  225. | id   | staff_id | amount |  
  226. +------+----------+--------+  
  227. |    1 |        1 |   3.20 |  
  228. |    2 |        2 |   9.30 |  
  229. |    3 |        1 |   1.84 |  
  230. |    4 |        1 |   2.28 |  
  231. |    5 |        2 |  20.19 |  
  232. |    6 |        2 |   1.80 |  
  233. |    9 |        1 |   3.19 |  
  234. |   19 |        1 |   9.92 |  
  235. |    1 |        1 |  13.20 |  
  236. |    2 |        2 |  91.30 |  
  237. |    3 |        1 |  13.84 |  
  238. |    4 |        1 |  25.28 |  
  239. |    5 |        2 |  28.28 |  
  240. |    6 |        2 | 113.33 |  
  241. +------+----------+--------+  
  242.   
  243. mysql> alter table payment_test add column payment_id int (11);   
  244.   
  245. mysql> select * from payment_test;  
  246. +------+----------+--------+------------+  
  247. | id   | staff_id | amount | payment_id |  
  248. +------+----------+--------+------------+  
  249. |    1 |        1 |  13.20 |       NULL |  
  250. |    2 |        2 |  91.30 |       NULL |  
  251. |    3 |        1 |  13.84 |       NULL |  
  252. |    4 |        1 |  25.28 |       NULL |  
  253. |    5 |        2 |  28.28 |       NULL |  
  254. |    6 |        2 | 113.33 |       NULL |  
  255. +------+----------+--------+------------+   
  256.   
  257. mysql> update payment_test set payment_id = 1 where id = 1 ;   
  258.   
  259. mysql> update payment_test set payment_id = 2 where id = 2 ;   
  260. = 6 where id = 6 ;    
  261.   
  262. mysql> update payment_test set payment_id = 3 where id = 3 ;    
  263.   
  264. mysql> update payment_test set payment_id = 4 where id = 4 ;   
  265.   
  266. mysql> update payment_test set payment_id = 5 where id = 5 ;   
  267. Query OK, 1 row affected (0.00 sec)  
  268. Rows matched: 1  Changed: 1  Warnings: 0  
  269.   
  270. mysql> update payment_test set payment_id = 6 where id = 6 ;    
  271.   
  272. mysql> insert into payment_test(id,payment_id) values (7,20);  
  273.   
  274. mysql> select * from payment_test;  
  275. +------+----------+--------+------------+  
  276. | id   | staff_id | amount | payment_id |  
  277. +------+----------+--------+------------+  
  278. |    1 |        1 |  13.20 |          1 |  
  279. |    2 |        2 |  91.30 |          2 |  
  280. |    3 |        1 |  13.84 |          3 |  
  281. |    4 |        1 |  25.28 |          4 |  
  282. |    5 |        2 |  28.28 |          5 |  
  283. |    6 |        2 | 113.33 |          6 |  
  284. |    7 |     NULL |   NULL |         20 |  
  285. +------+----------+--------+------------+  
  286.   
  287. mysql> update payment_test set payment_id = 3 where id = 5;  
  288.   
  289. mysql> select * from payment_test;  
  290. +------+----------+--------+------------+  
  291. | id   | staff_id | amount | payment_id |  
  292. +------+----------+--------+------------+  
  293. |    1 |        1 |  13.20 |          1 |  
  294. |    2 |        2 |  91.30 |          2 |  
  295. |    3 |        1 |  13.84 |          3 |  
  296. |    4 |        1 |  25.28 |          4 |  
  297. |    5 |        2 |  28.28 |          3 |  
  298. |    6 |        2 | 113.33 |          6 |  
  299. |    7 |     NULL |   NULL |         20 |  
  300. +------+----------+--------+------------+  
  301.   
  302. mysql> update payment_test set payment_id = 98 where id = 5;  
  303.   
  304. mysql> select * from payment_test;  
  305. +------+----------+--------+------------+  
  306. | id   | staff_id | amount | payment_id |  
  307. +------+----------+--------+------------+  
  308. |    1 |        1 |  13.20 |          1 |  
  309. |    2 |        2 |  91.30 |          2 |  
  310. |    3 |        1 |  13.84 |          3 |  
  311. |    4 |        1 |  25.28 |          4 |  
  312. |    5 |        2 |  28.28 |         98 |  
  313. |    6 |        2 | 113.33 |          6 |  
  314. |    7 |     NULL |   NULL |         20 |  
  315. +------+----------+--------+------------+  
  316.   
  317. mysql> select * from payment;  
  318. +------+----------+--------+  
  319. | id   | staff_id | amount |  
  320. +------+----------+--------+  
  321. |    1 |        1 |   3.20 |  
  322. |    2 |        2 |   9.30 |  
  323. |    3 |        1 |   1.84 |  
  324. |    4 |        1 |   2.28 |  
  325. |    5 |        2 |  20.19 |  
  326. |    6 |        2 |   1.80 |  
  327. |    9 |        1 |   3.19 |  
  328. |   19 |        1 |   9.92 |  
  329. +------+----------+--------+  
  330.   
  331. mysql> drop view payment_sum;  
  332.   
  333. mysql> show table status where comment='view' ;  
  334.   
  335. mysql> create or replace view payment_sum as  
  336.     -> select p.id,p.staff_id,p.amount from payment p   
  337.     -> left join payment_test pt   
  338.     -> on p.id = pt.payment_id;  
  339.   
  340. mysql> select *  from payment_sum;  
  341. +------+----------+--------+  
  342. | id   | staff_id | amount |  
  343. +------+----------+--------+  
  344. |    1 |        1 |   3.20 |  
  345. |    2 |        2 |   9.30 |  
  346. |    3 |        1 |   1.84 |  
  347. |    4 |        1 |   2.28 |  
  348. |    5 |        2 |  20.19 |  
  349. |    6 |        2 |   1.80 |  
  350. |    9 |        1 |   3.19 |  
  351. |   19 |        1 |   9.92 |  
  352. +------+----------+--------+    
  353.   
  354. mysql> update payment set amount = 333.333333 where id = 1;  
  355.   
  356. mysql> select *  from payment_sum;  
  357. +------+----------+--------+  
  358. | id   | staff_id | amount |  
  359. +------+----------+--------+  
  360. |    1 |        1 | 333.33 |  
  361. |    2 |        2 |   9.30 |  
  362. |    3 |        1 |   1.84 |  
  363. |    4 |        1 |   2.28 |  
  364. |    5 |        2 |  20.19 |  
  365. |    6 |        2 |   1.80 |  
  366. |    9 |        1 |   3.19 |  
  367. |   19 |        1 |   9.92 |  
  368. +------+----------+--------+  
  369.   
  370. mysql> show tables;  
  371. +--------------------+  
  372. | Tables_in_test1    |  
  373. +--------------------+  
  374. | ai                 |  
  375. | ai1                |  
  376. | ai2                |  
  377. | ai3                |  
  378. | autoincre_demo     |  
  379. | autoincre_demo_old |  
  380. | city               |  
  381. | city_memory        |  
  382. | country            |  
  383. | country_old        |  
  384. | myisam_char        |  
  385. | payment            |  
  386. | payment_2006       |  
  387. | payment_2007       |  
  388. | payment_all        |  
  389. | payment_sum        |  
  390. | payment_test       |  
  391. | salary             |  
  392. | t                  |  
  393. | t1                 |  
  394. | t1_test            |  
  395. | t2                 |  
  396. | t6                 |  
  397. | t8                 |  
  398. | t_binary           |  
  399. | t_date             |  
  400. | t_enum             |  
  401. | t_index            |  
  402. | t_old              |  
  403. | t_oldtable         |  
  404. | t_optimize         |  
  405. | t_test             |  
  406. | tab_memory         |  
  407. | test               |  
  408. | vc                 |  
  409. | vc_old             |  
  410. +--------------------+  
  411.   
  412. mysql> drop view payment_sum;  
  413.   
  414. mysql> show table status where comment='view'  ;  
  415.   
  416. mysql> create or replace view payment_sum as  
  417.     -> select p.id,p.staff_id,p.amount from payment p   
  418.     -> left join payment_test pt   
  419.     -> on p.id = pt.payment_id;  
  420.   
  421. mysql> select *  from payment_sum;  
  422. +------+----------+--------+  
  423. | id   | staff_id | amount |  
  424. +------+----------+--------+  
  425. |    1 |        1 |   3.20 |  
  426. |    2 |        2 |   9.30 |  
  427. |    3 |        1 |   1.84 |  
  428. |    4 |        1 |   2.28 |  
  429. |    5 |        2 |  20.19 |  
  430. |    6 |        2 |   1.80 |  
  431. |    9 |        1 |   3.19 |  
  432. |   19 |        1 |   9.92 |  
  433. +------+----------+--------+  
  434. rows in set (0.01 sec)  
  435.   
  436. mysql> update payment set amount = 333.333333 where id = 1;   
  437.   
  438. mysql> select *  from payment_sum;  
  439. +------+----------+--------+  
  440. | id   | staff_id | amount |  
  441. +------+----------+--------+  
  442. |    1 |        1 | 333.33 |  
  443. |    2 |        2 |   9.30 |  
  444. |    3 |        1 |   1.84 |  
  445. |    4 |        1 |   2.28 |  
  446. |    5 |        2 |  20.19 |  
  447. |    6 |        2 |   1.80 |  
  448. |    9 |        1 |   3.19 |  
  449. |   19 |        1 |   9.92 |  
  450. +------+----------+--------+  
  451.   
  452. mysql> drop view payment_sum;  
  453.   
  454. mysql> select id from payment where id = 5   
  455. +------+  
  456. | id   |  
  457. +------+  
  458. |    5 |  
  459. +------+  
  460.   
  461. mysql>  select * from payment where id = (  
  462.     ->  select id from payment_test where staff_id = 2 limit 1 );  
  463. +------+----------+--------+  
  464. | id   | staff_id | amount |  
  465. +------+----------+--------+  
  466. |    2 |        2 |   9.30 |  
  467. +------+----------+--------+   
  468.   
  469. mysql> select  * from payment_test where staff_id = 2 limit 1;  
  470. +------+----------+--------+------------+  
  471. | id   | staff_id | amount | payment_id |  
  472. +------+----------+--------+------------+  
  473. |    2 |        2 |  91.30 |          2 |  
  474. +------+----------+--------+------------+  
  475.   
  476. mysql> create or replace view payment_sum as  
  477.     ->  select * from payment where id = (  
  478.     ->  select id from payment_test where staff_id = 2 limit 1 ) ;  

  479. mysql> select * from payment_sum;  
  480. +------+----------+--------+  
  481. | id   | staff_id | amount |  
  482. +------+----------+--------+  
  483. |    2 |        2 |   9.30 |  
  484. +------+----------+--------+  
  485.   
  486. mysql> update payment set amount = 99.99999 where staff_id = 2;  
  487.   
  488. mysql> select * from payment_sum;  
  489. +------+----------+--------+  
  490. | id   | staff_id | amount |  
  491. +------+----------+--------+  
  492. |    2 |        2 | 100.00 |  
  493. +------+----------+--------+   
  494.   
  495. mysql> select *  from payment;  
  496. +------+----------+--------+  
  497. | id   | staff_id | amount |  
  498. +------+----------+--------+  
  499. |    1 |        1 | 333.33 |  
  500. |    2 |        2 | 100.00 |  
  501. |    3 |        1 |   1.84 |  
  502. |    4 |        1 |   2.28 |  
  503. |    5 |        2 | 100.00 |  
  504. |    6 |        2 | 100.00 |  
  505. |    9 |        1 |   3.19 |  
  506. |   19 |        1 |   9.92 |  
  507. +------+----------+--------+   
  508.   
  509. mysql> select id ,amount from payment where amount<10 ;  
  510. +------+--------+  
  511. | id   | amount |  
  512. +------+--------+  
  513. |    3 |   1.84 |  
  514. |    4 |   2.28 |  
  515. |    9 |   3.19 |  
  516. |   19 |   9.92 |  
  517. +------+--------+  
  518.   
  519. 3.嵌套视图  
  520. 备注:此处有些问题,没能按‘要求’更新  
  521. mysql> create or replace view payment_view as   
  522.     -> select id ,amount from payment where amount<10 with check option;  
  523.   
  524. mysql> create or replace view payment_view1 as   
  525.     -> select id ,amount from payment_view   
  526.     -> where amount>5 with local check option;  
  527.   
  528. mysql> create or replace view payment_view2 as   
  529.     -> select id ,amount from payment_view   
  530.     -> where amount>5 with cascaded check option;   
  531.   
  532. mysql> select * from payment_view1 limit 1;  
  533. +------+--------+  
  534. | id   | amount |  
  535. +------+--------+  
  536. |   19 |   9.92 |  
  537. +------+--------+  
  538.   
  539. mysql> update payment_view1 set amount = 10 where id = 19;  
  540.   
  541. mysql> update payment_view2 set amount = 10 where id = 19;  
  542.   
  543. mysql> select *from payment_view1;  
  544.   
  545. mysql> select *  from payment_view1;  

  546. mysql> select *  from payment_view2;  
  547.  
  548. mysql> show create view payment_view1 \G;  
  549. *************************** 1. row ***************************  
  550.                 View: payment_view1  
  551.          Create ViewCREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `payment_view1` AS select `payment_view`.`id` AS `id`,`payment_view`.`amount` AS `amount` from `payment_view` where (`payment_view`.`amount` > 5) WITH LOCAL CHECK OPTION  
  552. character_set_client: utf8  
  553. collation_connection: utf8_general_ci  
  554.   
  555. ERROR:   
  556. No query specified  
  557.   
  558. mysql> select * from   
  559.     -> information_schema.views   
  560.     -> where table_name = 'payment_view1' \G  
  561. *************************** 1. row ***************************  
  562.        TABLE_CATALOG: def  
  563.         TABLE_SCHEMA: test1  
  564.           TABLE_NAME: payment_view1  
  565.      VIEW_DEFINITION: select `payment_view`.`id` AS `id`,`payment_view`.`amount` AS `amount` from `test1`.`payment_view` where (`payment_view`.`amount` > 5)  
  566.         CHECK_OPTION: LOCAL  
  567.         IS_UPDATABLE: YES  
  568.              DEFINER: root@localhost  
  569.        SECURITY_TYPE: DEFINER  
  570. CHARACTER_SET_CLIENT: utf8  
  571. COLLATION_CONNECTION: utf8_general_ci   
  572.   
  573. mysql> select * from  information_schema.views  where table_name = 'payment_view'\G  
  574. *************************** 1. row ***************************  
  575.        TABLE_CATALOG: def  
  576.         TABLE_SCHEMA: test1  
  577.           TABLE_NAME: payment_view  
  578.      VIEW_DEFINITION: select `test1`.`payment`.`id` AS `id`,`test1`.`payment`.`amount` AS `amount` from `test1`.`payment` where (`test1`.`payment`.`amount` < 10)  
  579.         CHECK_OPTION: CASCADED  
  580.         IS_UPDATABLE: YES  
  581.              DEFINER: root@localhost  
  582.        SECURITY_TYPE: DEFINER  
  583. CHARACTER_SET_CLIENT: utf8  
  584. COLLATION_CONNECTION: utf8_general_ci  

0 0