Netsuite suiteQL get fields of tables and fields of views - odbc

How can I get a list of fields for tables or views from NetSuite using a SuiteQL connection?
I tried select * from oa_columns where table_name = 'account'; but that did not work.
I'm using the CDATA ODBC Connector

SELECT ColumnName FROM sys_tablecolumns WHERE TableName='Account' does the trick

Related

How can I list tables but not views from a Postgres DB, using R?

In ?DBI::dbListTables we can read :
This should include views and temporary objects
And indeed it does.
How can I see only tables though, excluding views ?
I'm using the driver RPostgres::Postgres() if it matters.
I suggest to the system catalog view pg_tables for tables:
dbGetQuery(con, "SELECT * FROM pg_tables")
The manual:
The view pg_tables provides access to useful information about each table in the database.
Does not contain views, materialized views or temporary tables, only regular tables (including UNLOGGED tables). See:
How to check if a table exists in a given schema
You may want to exclude system tables and only retrieve schema and table name:
dbGetQuery(con, "SELECT schemaname, tablename FROM pg_catalog.pg_tables WHERE schemaname !~ '^pg_' AND schemaname <> 'information_schema'")
I added explicit schema-qualification for the catalog table: pg_catalog.pg_tables. Typically not necessary, but to defend against a messed up search_path setting. See:
How does the search_path influence identifier resolution and the "current schema"
pg_views for views - if you need that:
dbGetQuery(con, "SELECT * FROM pg_views")
The view pg_views provides access to useful information about each view in the database.

OpenQuery for SQL Query

Kindly help me writing below query in openquery.Thanks in advance
INSERT INTO Tablename
SELECT * FROM tablename1 WHERE insertionorderid IN (
SELECT orderid FROM temp_table2)
If you are trying to insert into SQL Server the syntax would be
INSERT INTO dbo.[YOURTABLE] SELECT * FROM [MATCHING_TABLE] WHERE CLAUSE
The caveat here is that the two tables must have identical schemas or you will have to explicitly define the columns. Also this will not work properly for tables with identity columns

Oracle - Getting the fields of all tables in a database

I know that to find all the fields of a table I should use something like
sqlplus > desc testtable;
This lists all the fields of a table (here testtable)
But now, I have a list of tables in my database.
What is the way through which I can get the fields of all tables
in a given database using sqlplus?
I tried
sqlplus > desc <Databasename>; which didnot work.
Someone told me to use
sqlplus > select * from INFORMATION_SCHEMA.TABLES ; //gives error.
SQLPLUS > SELECT * FROM INFORMATION_SCHEMA.COLUMNS; //gives some error.
(At the bottom line, I am trying to get the database schema.)
I don't believe that the information_schema tables you can find in other dbs (SQL Server, PostGres, MySQL, etc) is in Oracle. I use to use the ALL_TAB_COLUMNS table to get at that type of information....maybe another alternative.
Link: ALL_TAB_COLUMNS

Show only VIEWS in SQLite

How can i see only VIEWS in SQLite.
.tables command list both views as well as tables. I want to see only VIEWS and not tables.
Thanks.
You can do:
SELECT sql FROM sqlite_master WHERE type = 'view';
In order to fine-tune it:
.headers on
select * from sqlite_master;
you will know what columns are available there.

Query to get all table names

Can any one tell me that how to get names of all tables of a database using asp.net
A newer method on SQL Server is to use the INFORMATION_SCHEMA Views to get the information:
SELECT table_name FROM INFORMATION_SCHEMA.Tables WHERE table_type='BASE TABLE'
This particular view also includes Views in its list of tables, which is why you need the where clause.
You didn't mention which database engine you are using. On SQL Server, you can query the sysobjects table and filter for objects with type U:
SELECT name FROM sysobjects WHERE type = 'U'
In case you are interested in the MySQL way to achieve this, you can use
DESCRIBE tableName;

Resources