Hello, 

when changing the name of schema (SQL command ALTER SCHEMA ... RENAME TO 
...), only tables reflect this change, but views keep references to old 
schema tables. So views defined in renamed schema references to tables in 
old schema (if exists). I can understand, why it behaves like this (views 
pointed to table IDs, which are not affected my renaming of schema), but I 
guess, that it is wrong behaviour, am I right? Tables behave correctly 
(reflect the schema change), views behave incorrectly (do not reflect the 
schema change). 

Regards, Stepan 

Simple test case running in H2 1.4.196 InMemory on Windows on Java 
1.8.0_152 64bit follows: 

create schema  "S01"; 
set schema "S01"; 
create table "T" ("ID" identity, "NAME" char(1));
create view "V" ("ID", "NAME") as select "ID", "NAME" from "T"; 
set schema to "PUBLIC"; 

create schema  "S02"; 
set schema "S02"; 
create table "T" ("ID" identity, "NAME" char(1));
create view "V" ("ID", "NAME") as select "ID", "NAME" from "T"; 
set schema to "PUBLIC"; 

set schema "S01"; 
insert into "T" ("ID", "NAME") values (1, 'a'); 
set schema "PUBLIC"; 

set schema "S02"; 
insert into "T" ("ID", "NAME") values (2, 'b'); 
set schema "PUBLIC"; 

select * from "S01"."T"; --correctly displays 1, a
select * from "S01"."V"; --correctly displays 1, a
select * from "S02"."T"; --correctly displays 2, b
select * from "S02"."V"; --correctly displays 2, b

alter schema "S02" rename to "SXX"; 
alter schema "S01" rename to "S02"; 
alter schema "SXX" rename to "S01"; 
set schema "PUBLIC"; 

select * from "S01"."T"; --correctly displays 2, b
select * from "S01"."V"; --incorrectly displays 1, a
select * from "S02"."T"; --correctly displays 1, a
select * from "S02"."V"; --incorrectly displays 2, b

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to h2-database+unsubscr...@googlegroups.com.
To post to this group, send email to h2-database@googlegroups.com.
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.

Reply via email to