Tagged: databases

0

Extracting table and column names from SQL query

(Not original article) sql-metadata is a Python library that uses a tokenized query returned by python-sqlparse and generates query metadata. This metadata can return column and table names from your supplied SQL query. Here are a couple of example from the sql-metadata github readme:...

0

Fetching Redshift table DDLs

So lately I got stumped by not having the ability to extract DDL/ table definition for a table in Redshift. Quick searches on the internet resulted in… below query, SELECT * FROM pg_table_def WHERE tablename = ‘table_name’ AND schemaname =...

0

Microsoft SQL Server query tips

Get column details of a table   Get column details of a table select name from sys.columns where object_name(object_id)=’table_name’   No related posts.

0

Process JSON data in SQL Server 2012

Source: http://mtkcode.blogspot.com/2014/08/parse-json-string-by-sql-script.html SQL Server 2016 and above support JSON_VALUE function to parse JSONs. To process JSONs in older versions add this function to database – https://github.com/khanhmai/Parse-JSON-String-by-SQL-script/blob/master/ParseJSON-FUNCTION.sql Then we can write queries such as below, — Query sample 1 select *...

0

pg_dump and pg_dumpall command helper (postgres)

  pg_dump pg_dump only dumps a single database. To backup global objects that are common to all databases in a cluster, such as roles and tablespaces, use pg_dumpall.Dumps can be output in script or archive file formats. Script dumps are plain-text files...

0

MySQL Tips

Show all users Drop all databases Delete all users in MySQL with specific name Check and duplicate user grants Reset root password (mysql 5.7)   Tip #1: Show all users MariaDB [(none)]> select User,Host from mysql.user order by User, Host; Output...