oracle - using default schema

This commit is contained in:
Jan Prochazka 2024-05-31 15:21:49 +02:00
parent 2723c41832
commit df60d40134
11 changed files with 24 additions and 12 deletions

View File

@ -57,6 +57,9 @@ const drivers = driverBases.map(driverBase => ({
password,
connectString: useDatabaseUrl ? databaseUrl : port ? `${server}:${port}/${serviceName}` : server,
});
if (database) {
await client.execute(`ALTER SESSION SET CURRENT_SCHEMA = ${database}`);
}
client._schema_name = database;
return client;
},

View File

@ -1,6 +1,6 @@
module.exports = `
select
owner as "schema_name",
-- owner as "schema_name",
table_name as "pure_name",
column_name as "column_name",
nullable as "is_nullable",

View File

@ -1,12 +1,12 @@
module.exports = `
select fk.constraint_name as "constraint_name",
fk.owner as "constraint_schema",
-- fk.owner as "constraint_schema",
fk.table_name as "pure_name",
fk.owner as "schema_name",
-- fk.owner as "schema_name",
fk.delete_rule as "update_action",
fk.delete_rule as "delete_action",
ref.table_name as "ref_table_name",
ref.owner as "ref_schema_name",
-- ref.owner as "ref_schema_name",
basecol.column_name as "column_name",
refcol.column_name as "ref_column_name"
from all_cons_columns refcol, all_cons_columns basecol, all_constraints ref, all_constraints fk

View File

@ -1,6 +1,6 @@
module.exports = `
select i.table_name as "tableName",
i.table_owner as "schemaName",
-- i.table_owner as "schemaName",
i.index_name as "constraintName",
i.index_type as "indexType",
i.uniqueness as "Unique",

View File

@ -1,6 +1,6 @@
module.exports = `
SELECT owner "schema_name"
, table_name "pure_name"
SELECT -- owner "schema_name"
table_name "pure_name"
, column_name "column_name"
, data_type "data_type"
FROM all_tab_columns av

View File

@ -1,5 +1,5 @@
module.exports = `
SELECT owner as schema_name,
SELECT -- owner as schema_name,
mview_name pure_name,
container_name,
'' || trim(

View File

@ -1,6 +1,6 @@
module.exports = `
select
pk.owner as "constraint_schema",
-- pk.owner as "constraint_schema",
pk.constraint_name as "constraint_name",
pk.owner as "schema_name",
pk.table_name as "pure_name",

View File

@ -1,7 +1,7 @@
module.exports = `
select
routine_name as "pure_name",
routine_schema as "schema_name",
-- routine_schema as "schema_name",
routine_definition as "definition",
standard_hash(routine_definition, 'MD5') as "hash_code",
routine_type as "object_type",

View File

@ -1,6 +1,6 @@
module.exports = `
select
owner "schema_name",
-- owner "schema_name",
table_name "pure_name"
from
all_tables

View File

@ -3,7 +3,7 @@ select avv.*,
ora_hash("create_sql") as "hash_code"
from (select
view_name as "pure_name",
owner as "schema_name",
-- owner as "schema_name",
SUBSTR(text_vc, 1, 3900) AS "create_sql"
from all_views av
where owner = '$owner' and text_vc is not null

View File

@ -1,6 +1,15 @@
const { SqlDumper, arrayToHexString, testEqualTypes } = global.DBGATE_TOOLS;
class Dumper extends SqlDumper {
createDatabase(name) {
this.putCmd(`CREATE USER c##${name}
IDENTIFIED BY ${name}
DEFAULT TABLESPACE users
TEMPORARY TABLESPACE temp
QUOTA 10M ON users;`, name);
}
/** @param type {import('dbgate-types').TransformType} */
transform(type, dumpExpr) {
switch (type) {