Back to home page

OSCL-LXR

 
 

    


0001 ---
0002 layout: global
0003 title: SHOW COLUMNS
0004 displayTitle: SHOW COLUMNS
0005 license: |
0006   Licensed to the Apache Software Foundation (ASF) under one or more
0007   contributor license agreements.  See the NOTICE file distributed with
0008   this work for additional information regarding copyright ownership.
0009   The ASF licenses this file to You under the Apache License, Version 2.0
0010   (the "License"); you may not use this file except in compliance with
0011   the License.  You may obtain a copy of the License at
0012  
0013      http://www.apache.org/licenses/LICENSE-2.0
0014  
0015   Unless required by applicable law or agreed to in writing, software
0016   distributed under the License is distributed on an "AS IS" BASIS,
0017   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0018   See the License for the specific language governing permissions and
0019   limitations under the License.
0020 ---
0021 
0022 ### Description
0023 
0024 Returns the list of columns in a table. If the table does not exist, an exception is thrown.
0025 
0026 ### Syntax
0027 
0028 ```sql
0029 SHOW COLUMNS table_identifier [ database ]
0030 ```
0031 
0032 ### Parameters
0033 
0034 * **table_identifier**
0035 
0036     Specifies the table name of an existing table. The table may be optionally qualified
0037     with a database name.
0038 
0039     **Syntax:** `{ IN | FROM } [ database_name . ] table_name`
0040 
0041     **Note:** Keywords `IN` and `FROM` are interchangeable.
0042 
0043 * **database**
0044 
0045     Specifies an optional database name. The table is resolved from this database when it
0046     is specified. When this parameter is specified then table
0047     name should not be qualified with a different database name. 
0048 
0049     **Syntax:** `{ IN | FROM } database_name`
0050 
0051     **Note:** Keywords `IN` and `FROM` are interchangeable.
0052 
0053 ### Examples
0054 
0055 ```sql
0056 -- Create `customer` table in `salesdb` database;
0057 USE salesdb;
0058 CREATE TABLE customer(
0059     cust_cd INT,
0060     name VARCHAR(100),
0061     cust_addr STRING);
0062 
0063 -- List the columns of `customer` table in current database.
0064 SHOW COLUMNS IN customer;
0065 +---------+
0066 | col_name|
0067 +---------+
0068 |  cust_cd|
0069 |     name|
0070 |cust_addr|
0071 +---------+
0072 
0073 -- List the columns of `customer` table in `salesdb` database.
0074 SHOW COLUMNS IN salesdb.customer;
0075 +---------+
0076 | col_name|
0077 +---------+
0078 |  cust_cd|
0079 |     name|
0080 |cust_addr|
0081 +---------+
0082 
0083 -- List the columns of `customer` table in `salesdb` database
0084 SHOW COLUMNS IN customer IN salesdb;
0085 +---------+
0086 | col_name|
0087 +---------+
0088 |  cust_cd|
0089 |     name|
0090 |cust_addr|
0091 +---------+
0092 ```
0093 
0094 ### Related Statements
0095 
0096 * [DESCRIBE TABLE](sql-ref-syntax-aux-describe-table.html)
0097 * [SHOW TABLE](sql-ref-syntax-aux-show-table.html)