Documentation
¶
Overview ¶
Package sql defines a series of SQL queries and SQL-related constants for interacting with databases, particularly MySQL and PostgreSQL. The code is organized into sections for MySQL and PostgreSQL, with each section containing relevant SQL queries and related constants.
Index ¶
Constants ¶
View Source
const ( /*------------------------ === Common Constants === --------------------------*/ SQLSelectAll string = `SELECT * FROM %s.%s` SQLUpdateRow string = `UPDATE %s SET %s = %s WHERE %s = %s` /*------------------------ === MySQL Constants === --------------------------*/ MySQLShowCreateTable string = `SHOW CREATE TABLE %s.%s` MySQLGetColumnDataType = `` /* 168-byte string literal not displayed */ MySQLSchemaSize string = `` /* 185-byte string literal not displayed */ MySQLShowDatabases string = `SHOW DATABASES` MySQLCountTableColumns string = `` /* 140-byte string literal not displayed */ MySQLCountTableRows string = `SELECT COUNT(*) FROM %s.%s` MySQLShowTables string = `SHOW TABLES` MySQLDropTable string = `DROP TABLE %s` MySQLDropDatabase string = `DROP DATABASE %s` MySQLCreateDatabase string = `CREATE DATABASE %s` MySQLTruncateTable string = `TRUNCATE TABLE %s` MySQLUse string = `USE %s` MySQLColumnsInfo string = `` /* 545-byte string literal not displayed */ MySQLSelectAllWithLimit string = `SELECT %s FROM %s.%s LIMIT %d OFFSET %d` MySQLGetTablesSize string = `` /* 226-byte string literal not displayed */ MySQLGetTableSize string = `` /* 200-byte string literal not displayed */ /*--------------------------- === PostgreSQL Constants === -----------------------------*/ PostgreSQLShowDatabases string = ` SELECT datname FROM pg_database WHERE NOT datistemplate ` PostgreSQLShowTables string = ` SELECT table_name FROM information_schema.tables WHERE table_schema = '%s' ` PostgreSQLSelectAllWithLimit string = `SELECT %s FROM %s.%s LIMIT %d OFFSET %d` PostgreSQLSchemaSize string = ` SELECT pg_size_pretty(pg_database_size(current_database())) AS "database size" ` PostgreSQLCountTableColumns string = `` /* 153-byte string literal not displayed */ PostgreSQLCountTableRows string = ` SELECT count(*) AS "Total_Rows" FROM %s.%s ` PostgreSQLTableSize string = `` /* 317-byte string literal not displayed */ PostgreSQLGetColumnDataType = `` /* 163-byte string literal not displayed */ PostgreSQLTableSizes string = `` /* 313-byte string literal not displayed */ PostgreSQLDropTable string = `DROP TABLE IF EXISTS %s` PostgreSQLDropDatabase string = `DROP DATABASE IF EXISTS %s` PostgreSQLCreateDatabase string = `CREATE DATABASE %s` PostgreSQLTruncateTable string = `TRUNCATE TABLE %s` PostgreSQLColumnsInfo string = `` /* 851-byte string literal not displayed */ // PostgreSQLShowCreateFunction is function that attempts to resemble the behaviour of mysql's 'show create' statement // the code is taken from an old answer found in // https://stackoverflow.com/questions/2593803/how-to-generate-the-create-table-sql-statement-for-an-existing-table-in-postgr PostgreSQLShowCreateFunction = `` /* 3214-byte string literal not displayed */ PostgreSQLShowCreate = `SELECT * FROM public.show_create_table('%s', '%s');` PostgreSQLDropShowCreateFunction = `DROP FUNCTION public.show_create_table(varchar, varchar);` )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DbType ¶
type DbType int
DbType represents an enumerated type for various database types.
Constants representing different database types.
Click to show internal directories.
Click to hide internal directories.