mysql>
select
*
from
test_main;
+
----+-------+
| id | value |
+
----+-------+
| 1 | ONE |
| 2 | TWO |
| 3 | THREE |
+
----+-------+
3
rows
in
set
(0.00 sec)
mysql>
create
table
test_main2
select
*
from
test_main;
Query OK, 3
rows
affected (0.04 sec)
Records: 3 Duplicates: 0 Warnings: 0
-- 创建视图, sql 语句加了括号, 报错。
CREATE
VIEW
view_test_main
AS
(
SELECT
*
FROM
test_main
UNION
ALL
SELECT
*
FROM
test_main2
);
ERROR 1064 (42000): You have an error
in
your SQL syntax;
check
the manual that
corresponds
to
your MySQL server version
for
the
right
syntax
to
use near
'UNION
ALL
SELECT * FROM test_main2
)'
at
line 5
-- 创建视图, sql 语句不加括号, 通过。
mysql>
CREATE
VIEW
view_test_main
->
AS
->
SELECT
*
FROM
test_main
->
UNION
ALL
->
SELECT
*
FROM
test_main2;
Query OK, 0
rows
affected (0.01 sec)