Oracle 11G table exists but not usable - oracle11g

I'm running Oracle 11G. Assume I have table named TEST_TABLE. I can see it when run :
SQL> SELECT TABLE_NAME FROM ALL_TABLES WHERE TABLE_NAME='TEST_TABLE';
TABLE_NAME
------------------------------
TEST_TABLE
But when I try to get table content I get an error:
SQL> SELECT * FROM table (TEST_TABLE);
SELECT * FROM table (TEST_TABLE)
*
ERROR at line 1:
ORA-00904: "TEST_TABLE": invalid identifier
Any help will be greatly appreciated !

SELECT * FROM table (TEST_TABLE);
That is the syntax for using a table function. Quite an advanced topic, not what you are looking for.
To access a table, simply do
SELECT * FROM TEST_TABLE;

Related

how to execute the query present as text in teradata

I have a table which a column contain select queries . can somebody help me on how to execute it without using SP.
Eg:
Table1:
Col1
---
Select * from tabl2 where id=1;
Select * from tabl2 where id=3;
enter code here
You can use
EXECUTE sp_executesql #Query
to run your T-SQL
EDIT:
For Teradata :
CALL DBC.SysExecSQL(string_expression)

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

List all tables in a DB using SQLite

I can't seem to find documentation (that I understand) on how to list all tables in a database. I've tried the following:
SELECT * FROM .table;
SELECT * FROM .tab;
SELECT * FROM .db;
SELECT * FROM world.db;
None of them worked. I'm just learning SQL, so forgive my ignorance. :0)
Try this:
SELECT * FROM sqlite_master WHERE type='table'
If you are in interactive mode, you can use this:
.tables
Another method with extra information:
.schema
https://sqlite.org/cli.html#querying_the_database_schema

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

SELECT INTO statement in sqlite

Does sqlite support the SELECT INTO statement?
Actually I am trying to save the data in table1 into table2 as a backup of my database before modifying the data.
When I try using the SELECT INTO statement:
SELECT * INTO equipments_backup FROM equipments;
I get a syntax error:
"Last Error Message:near "INTO":syntax
error".
Instead of
SELECT * INTO equipments_backup FROM equipments
try
CREATE TABLE equipments_backup AS SELECT * FROM equipments
sqlite does not support SELECT INTO.
You can probably use this form instead:
INSERT INTO equipments_backup SELECT * FROM equipments;
SQlite didn't have INSERT INTO syntax.
In 2019, I use TEMPORARY keyword to create temporary table and INSERT data to temp table:
CREATE TEMPORARY TABLE equipments_backup(field1 TEXT, field2 REAL)
INSERT INTO equipments_backup SELECT field1, field2 FROM equipments

Resources