I am trying to create tables which include the word "Messdaten" in it. Without ~ "Messdaten" part, code works well, but whenever I add ~ "Messdaten" it throws SQL State: 42601 sytax error. Do you have any idea what is wrong with the code? Its postgresql 9.2.
DECLARE
tbl_arr varchar[] := array['Messdaten2','dumptable'];
i varchar;
BEGIN
FOREACH i IN Array tbl_arr
LOOP
EXECUTE format('CREATE TABLE %I AS SELECT * FROM %I ~ "Messdaten"','backup_'||i,i);
END LOOP;
END;