我创建了一个表tvc
CREATE TABLE tvc(tvcid number(10), tvcname varchar2(15));
和另一个表uvc
CREATE TABLE uvc( uname varchar(10) );
如何将数据插入uvc表或从tvc表列名创建视图uvc?
答案 0 :(得分:2)
您只需为此创建视图,而不是创建单独的表:
CREATE view uvc
AS
SELECT tvcid as ID,
tvcname as Name
FROM tvc
答案 1 :(得分:0)
如何将数据插入uvc
表?
INSERT INTO uvc (uname)
SELECT tvc.tvcname
FROM tvc
[WHERE ..some conditions..]
请注意tvc.tvcname
和uvc.uname
类型不匹配,因此您应该更改
uvc.uname
数据类型为varchar2(15)
以避免错误。
如何从uvc
创建视图tvc
?
CREATE VIEW uvc AS
SELECT tvc.tvcname uname
FROM tvc
[WHERE ..some conditions..];
答案 2 :(得分:0)
with tb1 AS(
select 1 tvcid, 'gg' tvcname from dual
union all
select 2 tvcid, 'gg2' tvcname from dual
), tb2 as (
select 'gg' uname from dual
union all
select 'gg' uname from dual
)
SELECT DISTINCT * FROM
TB1 LEFT JOIN TB2 ON 1 = 1