vbp13
vbp13

Reputation: 1180

How to execute a query using snowsql cli client

I know this is basic. How do I run a query using snowsql cli client?

I ran the connection line: snowsql -a my_account_name -u my_user_name

i now see my_name#my_role@DatabaseName.(no schema)>

i'm trying to run a query after that. But after I hit return (mac), it just goes to new line and nothing happens.

i keep going through the documentation i see that you can run a stored query by id via the !result command

But how do I add a query to get a queryId?

Can I just run something like, select '1' and see the result?

Upvotes: 0

Views: 3774

Answers (2)

Kay
Kay

Reputation: 21

Make sure you are ending the query with a ';' before hitting return.

To get query id you can run the following query; select * from "SNOWFLAKE"."ACCOUNT_USAGE"."QUERY_HISTORY"; Of course, you can filter results.

Upvotes: 1

Suzy Lockwood
Suzy Lockwood

Reputation: 1170

Sounds like you might just be missing the semi-colon to indicate the end of the query. Try to type select 1; and enter to see if you get results. Running a query is similar to how you would type SQL in the Worksheets tab in the Snowflake Web UI, except you are pressing Enter instead of Run.

To query tables, you can use the fully qualified name like this:

select * from <database.schema.table>; 

Alternatively, you can run "use database database_name;" and "use schema schema_name;" to get to the database and schema you want to navigate to and run commands against the tables there.

Here is a quick tutorial that involves SnowSQL if you just want to get more comfortable with the tool: https://docs.snowflake.net/manuals/user-guide/getting-started-tutorial.html

Hope it helps.

Upvotes: 2

Related Questions