<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>OpenText Analytics Database 26.2.x – Using multiple schemas</title>
    <link>/en/admin/configuring-db/designing-logical-schema/using-multiple-schemas/</link>
    <description>Recent content in Using multiple schemas on OpenText Analytics Database 26.2.x</description>
    <generator>Hugo -- gohugo.io</generator>
    
	  <atom:link href="/en/admin/configuring-db/designing-logical-schema/using-multiple-schemas/index.xml" rel="self" type="application/rss+xml" />
    
    
      
        
      
    
    
    <item>
      <title>Admin: Multiple schema examples</title>
      <link>/en/admin/configuring-db/designing-logical-schema/using-multiple-schemas/multiple-schema-examples/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/configuring-db/designing-logical-schema/using-multiple-schemas/multiple-schema-examples/</guid>
      <description>
        
        
        &lt;p&gt;This section provides examples of when and how you might want to use multiple schemas to separate database users. These examples fall into two categories: using multiple private schemas and using a combination of private schemas (i.e. schemas limited to a single user) and shared schemas (i.e. schemas shared across multiple users).&lt;/p&gt;
&lt;h2 id=&#34;using-multiple-private-schemas&#34;&gt;Using multiple private schemas&lt;/h2&gt;
&lt;p&gt;Using multiple private schemas is an effective way of separating database users from one another when sensitive information is involved. Typically a user is granted access to only one schema and its contents, thus providing database security at the schema level. Database users can be running different applications, multiple copies of the same application, or even multiple instances of the same application. This enables you to consolidate applications on one database to reduce management overhead and use resources more effectively. The following examples highlight using multiple private schemas.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Using multiple schemas to separate users and their unique applications&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In this example, both database users work for the same company. One user (HRUser) uses a Human Resource (HR) application with access to sensitive personal data, such as salaries, while another user (MedUser) accesses information regarding company healthcare costs through a healthcare management application. HRUser should not be able to access company healthcare cost information and MedUser should not be able to view personal employee data.&lt;/p&gt;
&lt;p&gt;To grant these users access to data they need while restricting them from data they should not see, two schemas are created with appropriate user access, as follows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;HRSchema—A schema owned by HRUser that is accessed by the HR application.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;HealthSchema—A schema owned by MedUser that is accessed by the healthcare management application.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Using multiple schemas to support multitenancy&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This example is similar to the last example in that access to sensitive data is limited by separating users into different schemas. In this case, however, each user is using a virtual instance of the same application.&lt;/p&gt;
&lt;p&gt;An example of this is a retail marketing analytics company that provides data and software as a service (SaaS) to large retailers to help them determine which promotional methods they use are most effective at driving customer sales.&lt;/p&gt;
&lt;p&gt;In this example, each database user equates to a retailer, and each user only has access to its own schema. The retail marketing analytics company provides a virtual instance of the same application to each retail customer, and each instance points to the user’s specific schema in which to create and update tables. The tables in these schemas use the same names because they are created by instances of the same application, but they do not conflict because they are in separate schemas.&lt;/p&gt;
&lt;p&gt;Example of schemas in this database could be:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;MartSchema—A schema owned by MartUser, a large department store chain.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;PharmSchema—A schema owned by PharmUser, a large drug store chain.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Using multiple schemas to migrate to a newer version of an application&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Using multiple schemas is an effective way of migrating to a new version of a software application. In this case, a new schema is created to support the new version of the software, and the old schema is kept as long as necessary to support the original version of the software. This is called a “rolling application upgrade.”&lt;/p&gt;
&lt;p&gt;For example, a company might use a HR application to store employee data. The following schemas could be used for the original and updated versions of the software:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;HRSchema—A schema owned by HRUser, the schema user for the original HR application.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;V2HRSchema—A schema owned by V2HRUser, the schema user for the new version of the HR application.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&#34;combining-private-and-shared-schemas&#34;&gt;Combining private and shared schemas&lt;/h2&gt;
&lt;p&gt;The previous examples illustrate cases in which all schemas in the database are private and no information is shared between users. However, users might want to share common data. In the retail case, for example, MartUser and PharmUser might want to compare their per store sales of a particular product against the industry per store sales average. Since this information is an industry average and is not specific to any retail chain, it can be placed in a schema on which both users are granted &lt;a href=&#34;../../../../../en/sql-reference/statements/grant-statements/grant-schema/&#34;&gt;USAGE privileges&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Example of schemas in this database might be:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;MartSchema—A schema owned by MartUser, a large department store chain.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;PharmSchema—A schema owned by PharmUser, a large drug store chain.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;IndustrySchema—A schema owned by DBUser (from the retail marketing analytics company) on which both MartUser and PharmUser have USAGE privileges. It is unlikely that retailers would be given any privileges beyond USAGE on the schema and SELECT on one or more of its tables.&lt;/p&gt;


&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
    <item>
      <title>Admin: Creating schemas</title>
      <link>/en/admin/configuring-db/designing-logical-schema/using-multiple-schemas/creating-schemas/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/configuring-db/designing-logical-schema/using-multiple-schemas/creating-schemas/</guid>
      <description>
        
        
        &lt;p&gt;You can create as many schemas as necessary for your database. For example, you could create a schema for each database user. However, schemas and users are not synonymous as they are in Oracle.&lt;/p&gt;
&lt;p&gt;By default, only a superuser can create a schema or give a user the right to create a schema. (See &lt;a href=&#34;../../../../../en/sql-reference/statements/grant-statements/grant-db/#&#34;&gt;GRANT (database)&lt;/a&gt; in the SQL Reference Manual.)&lt;/p&gt;
&lt;p&gt;To create a schema use the &lt;a href=&#34;../../../../../en/sql-reference/statements/create-statements/create-schema/#&#34;&gt;CREATE SCHEMA&lt;/a&gt; statement, as described in the SQL Reference Manual.&lt;/p&gt;

      </description>
    </item>
    
    <item>
      <title>Admin: Specifying objects in multiple schemas</title>
      <link>/en/admin/configuring-db/designing-logical-schema/using-multiple-schemas/specifying-objects-multiple-schemas/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/configuring-db/designing-logical-schema/using-multiple-schemas/specifying-objects-multiple-schemas/</guid>
      <description>
        
        
        &lt;p&gt;Once you create two or more schemas, each SQL statement or function must identify the schema associated with the object you are referencing. You can specify an object within multiple schemas by:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Qualifying the object name by using the schema name and object name separated by a dot. For example, to specify &lt;code&gt;MyTable&lt;/code&gt;, located in &lt;code&gt;Schema1&lt;/code&gt;, qualify the name as &lt;code&gt;Schema1.MyTable&lt;/code&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Using a search path that includes the desired schemas when a referenced object is unqualified. By &lt;a href=&#34;../../../../../en/admin/configuring-db/designing-logical-schema/using-multiple-schemas/setting-search-paths/#&#34;&gt;Setting search paths&lt;/a&gt;, the database automatically searches the specified schemas to find the object.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

      </description>
    </item>
    
    <item>
      <title>Admin: Setting search paths</title>
      <link>/en/admin/configuring-db/designing-logical-schema/using-multiple-schemas/setting-search-paths/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/configuring-db/designing-logical-schema/using-multiple-schemas/setting-search-paths/</guid>
      <description>
        
        
        &lt;p&gt;Each user session has a search path of schemas. The database uses this search path to find tables and user-defined functions (UDFs) that are unqualified by their schema name. A session search path is initially set from the user&#39;s profile. You can change the session&#39;s search path at any time by calling 
&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/statements/set-statements/set-search-path/#&#34;&gt;SET SEARCH_PATH&lt;/a&gt;&lt;/code&gt;. This search path remains in effect until the next &lt;code&gt;SET SEARCH_PATH&lt;/code&gt; statement, or the session ends.&lt;/p&gt;
&lt;p&gt;&lt;a name=&#34;Viewing&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&#34;viewing-the-current-search-path&#34;&gt;Viewing the current search path&lt;/h2&gt;
&lt;p&gt;
&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/statements/show/#&#34;&gt;SHOW SEARCH_PATH&lt;/a&gt;&lt;/code&gt; returns the session&#39;s current search path. For example:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
=&amp;gt; SHOW SEARCH_PATH;
    name     |                      setting
-------------+---------------------------------------------------
 search_path | &amp;#34;$user&amp;#34;, public, v_catalog, v_monitor, v_internal
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Schemas are listed in descending order of precedence. The first schema has the highest precedence in the search order. If this schema exists, it is also defined as the current schema, which is used for tables that are created with unqualified names. You can identify the current schema by calling the function 
&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/functions/system-information-functions/current-schema/#&#34;&gt;CURRENT_SCHEMA&lt;/a&gt;&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT CURRENT_SCHEMA;
 current_schema
----------------
 public
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;setting-the-user-search-path&#34;&gt;Setting the user search path&lt;/h2&gt;
&lt;p&gt;A session search path is initially set from the user&#39;s profile. If the search path in a user profile is not set by 
&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/statements/create-statements/create-user/#&#34;&gt;CREATE USER&lt;/a&gt;&lt;/code&gt; or 
&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/statements/alter-statements/alter-user/#&#34;&gt;ALTER USER&lt;/a&gt;&lt;/code&gt;, it is set to the database default:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; CREATE USER agent007;
CREATE USER
=&amp;gt; \c - agent007
You are now connected as user &amp;#34;agent007&amp;#34;.
=&amp;gt; SHOW SEARCH_PATH;
    name     |                      setting
-------------+---------------------------------------------------
 search_path | &amp;#34;$user&amp;#34;, public, v_catalog, v_monitor, v_internal
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;code&gt;$user&lt;/code&gt; resolves to the session user name—in this case, &lt;code&gt;agent007&lt;/code&gt;—and has the highest precedence. If a schema &lt;code&gt;agent007&lt;/code&gt; exists, the database begins searches for unqualified tables in that schema. Also, calls to 
&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/functions/system-information-functions/current-schema/#&#34;&gt;CURRENT_SCHEMA&lt;/a&gt;&lt;/code&gt; return this schema. Otherwise, the database uses &lt;code&gt;public&lt;/code&gt; as the current schema and begins searches in it.&lt;/p&gt;
&lt;p&gt;Use 
&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/statements/alter-statements/alter-user/#&#34;&gt;ALTER USER&lt;/a&gt;&lt;/code&gt; to modify an existing user&#39;s search path. These changes overwrite all non-system schemas in the search path, including &lt;code&gt;$USER&lt;/code&gt;. System schemas are untouched. Changes to a user&#39;s search path take effect only when the user starts a new session; current sessions are unaffected.

&lt;div class=&#34;admonition important&#34; role=&#34;alert&#34;&gt;
&lt;h4 class=&#34;admonition-head&#34;&gt;Important&lt;/h4&gt;
After modifying the user&#39;s search path, &lt;a href=&#34;../../../../../en/admin/db-users-and-privileges/db-privileges/viewing-privileges-granted-on-objects/&#34;&gt;verify that the user has access privileges&lt;/a&gt; to all schemas that are on the updated search path.
&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;For example, the following statements modify &lt;code&gt;agent007&lt;/code&gt;&#39;s search path, and grant access privileges to schemas and tables that are on the new search path:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; ALTER USER agent007 SEARCH_PATH store, public;
ALTER USER
=&amp;gt; GRANT ALL ON SCHEMA store, public TO agent007;
GRANT PRIVILEGE
=&amp;gt; GRANT SELECT ON ALL TABLES IN SCHEMA store, public TO agent007;
GRANT PRIVILEGE
=&amp;gt; \c - agent007
You are now connected as user &amp;#34;agent007&amp;#34;.
=&amp;gt; SHOW SEARCH_PATH;
    name     |                     setting
-------------+-------------------------------------------------
 search_path | store, public, v_catalog, v_monitor, v_internal
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;To verify a user&#39;s search path, query the system table 
&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/system-tables/v-catalog-schema/users/#&#34;&gt;USERS&lt;/a&gt;&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;=&amp;gt; SELECT search_path FROM USERS WHERE user_name=&amp;#39;agent007&amp;#39;;
                   search_path
-------------------------------------------------
 store, public, v_catalog, v_monitor, v_internal
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;To revert a user&#39;s search path to the database default settings, call &lt;code&gt;ALTER USER&lt;/code&gt; and set the search path to &lt;code&gt;DEFAULT&lt;/code&gt;. For example:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
=&amp;gt; ALTER USER agent007 SEARCH_PATH DEFAULT;
ALTER USER
=&amp;gt; SELECT search_path FROM USERS WHERE user_name=&amp;#39;agent007&amp;#39;;
                    search_path
---------------------------------------------------
 &amp;#34;$user&amp;#34;, public, v_catalog, v_monitor, v_internal
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;ignored-search-path-schemas&#34;&gt;Ignored search path schemas&lt;/h2&gt;
&lt;p&gt;The database only searches among existing schemas to which the current user has access privileges. If a schema in the search path does not exist or the user lacks access privileges to it, the database silently excludes it from the search. For example, if &lt;code&gt;agent007&lt;/code&gt; lacks SELECT privileges to schema &lt;code&gt;public&lt;/code&gt;, the database silently skips this schema. The database returns with an error only if it cannot find the table anywhere on the search path.&lt;/p&gt;
&lt;h2 id=&#34;setting-session-search-path&#34;&gt;Setting session search path&lt;/h2&gt;
&lt;p&gt;The database initially sets a session&#39;s search path from the user&#39;s profile. You can change the current session&#39;s search path with 
&lt;code&gt;&lt;a href=&#34;../../../../../en/sql-reference/statements/set-statements/set-search-path/#&#34;&gt;SET SEARCH_PATH&lt;/a&gt;&lt;/code&gt;. You can use &lt;code&gt;SET SEARCH_PATH&lt;/code&gt; in two ways:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Explicitly set the session search path to one or more schemas. For example:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
=&amp;gt; \c - agent007
You are now connected as user &amp;#34;agent007&amp;#34;.
dbadmin=&amp;gt; SHOW SEARCH_PATH;
    name     |                      setting
-------------+---------------------------------------------------
 search_path | &amp;#34;$user&amp;#34;, public, v_catalog, v_monitor, v_internal
(1 row)

=&amp;gt; SET SEARCH_PATH TO store, public;
SET
=&amp;gt; SHOW SEARCH_PATH;
    name     |                     setting
-------------+-------------------------------------------------
 search_path | store, public, v_catalog, v_monitor, v_internal
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Set the session search path to the database default:&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;
=&amp;gt; SET SEARCH_PATH TO DEFAULT;
SET
=&amp;gt; SHOW SEARCH_PATH;
    name     |                      setting
-------------+---------------------------------------------------
 search_path | &amp;#34;$user&amp;#34;, public, v_catalog, v_monitor, v_internal
(1 row)
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;code&gt;SET SEARCH_PATH&lt;/code&gt; overwrites all non-system schemas in the search path, including &lt;code&gt;$USER&lt;/code&gt;. System schemas are untouched.&lt;/p&gt;

      </description>
    </item>
    
    <item>
      <title>Admin: Creating objects that span multiple schemas</title>
      <link>/en/admin/configuring-db/designing-logical-schema/using-multiple-schemas/creating-objects-that-span-multiple-schemas/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      
      <guid>/en/admin/configuring-db/designing-logical-schema/using-multiple-schemas/creating-objects-that-span-multiple-schemas/</guid>
      <description>
        
        
        &lt;p&gt;OpenText™ Analytics Database supports &lt;a class=&#34;glosslink&#34; href=&#34;../../../../../en/glossary/view/&#34; title=&#34;A named logical relation specified by an associated query that can be accessed similarly to a table in the FROM clause of a SQL statement.&#34;&gt;views&lt;/a&gt; that reference tables across multiple schemas. For example, a user might need to compare employee salaries to industry averages. In this case, the application queries two schemas:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Shared schema &lt;code&gt;IndustrySchema&lt;/code&gt; for salary averages&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Private schema &lt;code&gt;HRSchema&lt;/code&gt; for company-specific salary information&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;img src=&#34;../../../../../images/projection1.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Best Practice:&lt;/strong&gt; When creating objects that span schemas, use qualified table names. This naming convention avoids confusion if the query path or table structure within the schemas changes at a later date.&lt;/p&gt;

      </description>
    </item>
    
  </channel>
</rss>
