Catalin Catalin - 1 year ago 78
SQL Question

Regex put name schema for 'table' in select query syntax

How can I put with regex, schema name table, for query select?

Query doesn't have fixed size.


select * from t1 union select * from t2


select * from schema1.t1 union select * from schema1.t2


Answer Source

(1) If you are using it in a code, maybe you can do a search and replace at front end as Luk suggested.

(2) Alternatively, in your current session you can set default schema as schema1 so your query would work without schema name. But it would depend on your database name.

Like in Oracle you can do


Now select * from t1 would effectively mean select * from schema1.t1.

You can search how to set default schema in <your database> in google and you would get syntax for other databases as well.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download