<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: PROC SQL Getting a list from an Oracle Database in SAS Data Science</title>
    <link>https://communities.sas.com/t5/SAS-Data-Science/PROC-SQL-Getting-a-list-from-an-Oracle-Database/m-p/963055#M11035</link>
    <description>&lt;P&gt;You could make use of the Oracle dictionary tables. If you run this query in SQL Passthru it will list all tables you have access to:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SELECT owner, table_name FROM all_tables&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 31 Mar 2025 20:21:21 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2025-03-31T20:21:21Z</dc:date>
    <item>
      <title>PROC SQL Getting a list from an Oracle Database</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/PROC-SQL-Getting-a-list-from-an-Oracle-Database/m-p/963033#M11033</link>
      <description>&lt;P&gt;I have an Oracle database that contains multiple tables some of which I can readily access because I know the names and other which I cannot access because I do not know the names. I have the proper information regarding passwords and location but I don't know the syntax for creating a list of the table names in the data base.&amp;nbsp; To access specific tables I am using the following code which does work:&lt;/P&gt;
&lt;P&gt;proc sql; &lt;BR /&gt;connect to odbc (dsn='DSNAME' uid=UIDNAME pwd='PASSWORDXXXXXXX'); &lt;BR /&gt;create table OUTDAT as select * from connection to odbc (select * from UIDNAME .TABLENAME);&lt;BR /&gt;RUN;&lt;/P&gt;
&lt;P&gt;DATA OUTDAT; SET OUTDAT;RUN;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does anyone know if there is a way to obtain a list of all of the tables in the Oracle database using the same ODBC connect syntax or do I need something else?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Mar 2025 17:18:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/PROC-SQL-Getting-a-list-from-an-Oracle-Database/m-p/963033#M11033</guid>
      <dc:creator>kodmfl</dc:creator>
      <dc:date>2025-03-31T17:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL Getting a list from an Oracle Database</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/PROC-SQL-Getting-a-list-from-an-Oracle-Database/m-p/963047#M11034</link>
      <description>&lt;P&gt;Normally would be told what schema to use in the Oracle database. You would then create a libref to connect to that specific schema in the Oracle database.&amp;nbsp; The schema might be already set in the ODBC DSN you are using.&amp;nbsp; But you should be able to override with the SCHEMA= option.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname myora odbc 
  dsn='DSNAME'
  uid=UIDNAME pwd='PASSWORDXXXXXXX'
  schema='oracle_schema_name' 
;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and then the normal SAS tools for finding out what datasets exist in a library will work.&amp;nbsp; Such as PROC CONTENTS (or PROC DATASETS).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data=mylib._all_ out=contents noprint;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or the DICTIONARY metadata views.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table datasets as 
select * from dictionary.tables
where libname='MYLIB'
;
create table variables as 
select * from dictionary.columns
where libname='MYLIB'
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Since you are using ODBC you could also use the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/acreldb/p1f29m86u65hken1deqcybowtgma.htm" target="_self"&gt;special ODBC catalog queries&lt;/A&gt;.&amp;nbsp; Note that if you already have a connection created with libref you can use that libref in your PROC SQL instead of making a new connection.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
connect using mylib;
create table datasets as 
select * from connection to mylib
(ODBC:SQLTables(,,))
;
create table variables as 
select * from connection to mylib
(ODBC:SQLColumns(,,,))
;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Mar 2025 18:42:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/PROC-SQL-Getting-a-list-from-an-Oracle-Database/m-p/963047#M11034</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-03-31T18:42:49Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL Getting a list from an Oracle Database</title>
      <link>https://communities.sas.com/t5/SAS-Data-Science/PROC-SQL-Getting-a-list-from-an-Oracle-Database/m-p/963055#M11035</link>
      <description>&lt;P&gt;You could make use of the Oracle dictionary tables. If you run this query in SQL Passthru it will list all tables you have access to:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SELECT owner, table_name FROM all_tables&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 31 Mar 2025 20:21:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Science/PROC-SQL-Getting-a-list-from-an-Oracle-Database/m-p/963055#M11035</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2025-03-31T20:21:21Z</dc:date>
    </item>
  </channel>
</rss>

