No such table in ZSS Test Client window - zumero

Using the Test Client, I get a "No Such Table" error when trying to select some data from my database - sync was successful.
Here's my query: select * from schema.TableName.

Try with:
SELECT * FROM TableName
i.e. without the schema name in front
Or, if the table was from a schema other than dbo, it will be prefixed by the schema name + _ (see SQL Server Schemas in the ZSS Manager docs). So if the original table was MySchema.TableName, you'd use:
SELECT * from MySchema_TableName

Related

Supabase PostgreSQL query error: Failed to run sql query: column __ does not exist

Every solution I see has to do with people having case sensitive column names.
The query select * from users works, but when I say select * from users where username=maxspiri, I get error column maxspiri doesn't exist. Here is my table:
Since maxspiri is a string, you need to wrap it in single quotes.
select * from users where username='maxspiri'

How to write a select statement for a table in postgres that is inside a schema?

I have a postgres DB and inside of it there are many schemas.
Each one of those schemas contains tables. For example:
Schema Name: personal has tables actions_takes, page_views etc
How can i write a SQL query or ActiveRecord query to query the table inside the schema?
Something like:
select * from actions_takes where user_id = 123;
I can create a model for each table and query it that way, but i want to write a script that passed a user goes over all tables and get the data for that user.
in pgAdmin 4 web console should use double quotation marks like following select statement
SELECT "col1", "col2"
FROM "schemaName".profile;
Point to specific table within a given schema using a dot notation schema.table_name. In your case it translates to
select * from personal.actions_takes where user_id = 123;
For me this query worked : select * from schemaName."Table_Name"

psycopg2 change schema does not work

I am writing a simple python prog to connect and display results from Postgres table this is on AWS RDS. I have table mytest in public schema.
connection = psycopg2.connect(dbname='some_test',
user='user1',
host='localhost',
password='userpwd',
port=postgres_port)
cursor = connection.cursor()
cursor.execute("SET SEARCH_PATH TO public;")
cursor.execute("SELECT * FROM mytest;")
But this throws an error
psycopg2.ProgrammingError: relation "mytest" does not exist
LINE 1: SELECT * FROM mytest;
Connection is successful and I can query other basetables like
SELECT table_name FROM information_schema.tables
It is just that I cannot change to any other schema. I googled and tried all kinds of SET SERACH_PATH and commit it and recreate cursor etc. but no use. I cannot query any other schema.
ALTER USER username SET search_path = schema1,schema2;
After setting this the query works fine!

ERROR: relation "stg_data_bt_sur" does not exist

I've created a table in postgresql which is OK and I'm able to do select/insert using SQL manager tool or Navicat Lite tool.
But, when I'm trying to make simple select from LINUX(ubuntu) I have following message:
postgres=# select count(*) from stg_data_brest_surgery;
ERROR: relation "stg_data_brest_surgery" does not exist
STATEMENT: select count(*) from stg_data_brest_surgery;
ERROR: relation "stg_data_brest_surgery" does not exist.
I also used table name with double quotes - same result.
Any idea what's the issue?
Chances are the schema isn't in your search path, Try \dn to list namespaces and then you can either add the schema like:
SELECT * from "schema"."table";
Or you can set your search path:
SET search_path="schema";
SELECT * FROM "table";
RESET search_path;

Creating a T-SQL temp table on another server machine

I'm using SQL Query Analyzer to build a report from the database on one machine (A), and I'd like to create a temp table on a database server on another machine(B) and load it with the data from machine A.
To be more specific, I have a report that runs on machine A (machine.a.com), pulling from schema tst. Using SQL Query Analyzer, I log into the server at machine.a.com and then have access to the tst schema:
USE tst;
SELECT *
FROM prospect;
I would like to create a temp table from this query window, only I'd like it built on another machine (call it machine.b.com). What syntax would I use for this? My guess is something like:
CREATE TABLE machine.b.com.#temp_prospect_list(name varchar(45) Not Null, id decimal(10) Not Null);
And then I'd like to load this new table with something like:
INSERT INTO machine.b.com.#temp_prospect_list VALUES (
USE tst;
SELECT *
FROM prospect; );
The syntax to access a remote server in T-SQL is to fully qualify any table name with the following (brackets included when necessary):
[LinkedServer].[RemoteDatabase].[User].[Table]
So, for example, to run a SELECT statement on one server that accesses a table on another server:
SELECT * FROM [machine.b.com].tst.dbo.table7;