<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[sql server - JBay Solutions - The Dev Blog]]></title><description><![CDATA[JBay Solutions Development Blog on Java, Android, Play2 and others]]></description><link>http://blog.jbaysolutions.com/</link><generator>Ghost 0.7</generator><lastBuildDate>Wed, 16 Oct 2024 01:15:05 GMT</lastBuildDate><atom:link href="http://blog.jbaysolutions.com/tag/sql-server/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[SQL queries to get table and columns names for MySQL, PosgreSQL and SQL Server]]></title><description><![CDATA[<p>Something that now and then are always needed, the SQL queries to get the list of table names from a database, or the column names for a table. <br>
Below are the queries for MySQL, PostgreSQL and Microsoft SQL server. </p>

<h3 id="mysql">MySQL</h3>

<p>To get the table list:</p>

<pre><code>show tables;
</code></pre>

<p>To get the</p>]]></description><link>http://blog.jbaysolutions.com/2015/12/01/sql-table-and-columns-from-mysql-postgresql-sqlserver/</link><guid isPermaLink="false">8f422c92-5eba-4227-8ebe-a3591f977eaf</guid><category><![CDATA[sql]]></category><category><![CDATA[mysql]]></category><category><![CDATA[postgresql]]></category><category><![CDATA[sql server]]></category><dc:creator><![CDATA[Gustavo Santos]]></dc:creator><pubDate>Tue, 01 Dec 2015 20:09:10 GMT</pubDate><content:encoded><![CDATA[<p>Something that now and then are always needed, the SQL queries to get the list of table names from a database, or the column names for a table. <br>
Below are the queries for MySQL, PostgreSQL and Microsoft SQL server. </p>

<h3 id="mysql">MySQL</h3>

<p>To get the table list:</p>

<pre><code>show tables;
</code></pre>

<p>To get the column list for a table:</p>

<pre><code>show columns from &lt;tableName&gt;;
</code></pre>

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>  
<!-- Horizontal For Posts - Text Only -->  
<ins class="adsbygoogle" style="display:inline-block;width:728px;height:90px" data-ad-client="ca-pub-1311169549359552" data-ad-slot="3316155422"></ins>
<script>  
(adsbygoogle = window.adsbygoogle || []).push({});
</script>  

<p><br><hr></p>

<h3 id="postgresql">PostgreSQL</h3>

<p>To get the table list:</p>

<pre><code>SELECT table_name FROM information_schema.tables WHERE table_catalog ='&lt;dbName&gt;' and table_schema = 'public';
</code></pre>

<p>To get the column list for a table:</p>

<pre><code>SELECT column_name FROM information_schema.columns where table_catalog = '&lt;dbName&gt;' and table_name = '&lt;tableName&gt;';
</code></pre>

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>  
<!-- Horizontal For Posts - Text Only -->  
<ins class="adsbygoogle" style="display:inline-block;width:728px;height:90px" data-ad-client="ca-pub-1311169549359552" data-ad-slot="3316155422"></ins>
<script>  
(adsbygoogle = window.adsbygoogle || []).push({});
</script>  

<p><br><hr></p>

<h3 id="sqlserver">SQL Server</h3>

<p>To get the table list:</p>

<pre><code>SELECT TABLE_NAME FROM &lt;dbName&gt;.INFORMATION_SCHEMA.Tables;
</code></pre>

<p>To get the column list for a table:</p>

<pre><code>SELECT COLUMN_NAME FROM &lt;dbName&gt;.INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '&lt;tableName&gt;';
</code></pre>

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>  
<!-- Horizontal For Posts - Text Only -->  
<ins class="adsbygoogle" style="display:inline-block;width:728px;height:90px" data-ad-client="ca-pub-1311169549359552" data-ad-slot="3316155422"></ins>
<script>  
(adsbygoogle = window.adsbygoogle || []).push({});
</script>  

<p><br>  </p>

<hr>]]></content:encoded></item></channel></rss>