Tags:
tag this topic
create new tag
view all tags
---++Useful SQL ---+++Getting information * Get table information * describe MY_DB_NAME; * Get the column names from your table * select COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='MY_DB_NAME'; * See what processes are running * SHOW [FULL] PROCESSLIST; * Get size of all databases * SELECT table_schema "Database Name", sum( data_length + index_length) / 1024 / 1024 "Database Size in MB" FROM information_schema.TABLES GROUP BY table_schema; * Get size breakdown for a single database named "my_database" * SELECT table_name, table_rows, data_length, index_length, round(((data_length + index_length) / 1024 / 1024),2) "Size in MB" FROM information_schema.TABLES WHERE table_schema = "my_database"; * Get all columns of a table are enums * select COLUMN_NAME from information_schema.COLUMNS WHERE table_schema = "MODEL_DB" and TABLE_NAME='CPLEX_CONFIGURATION_12_1_MILP' and DATA_TYPE = 'enum'; ---+++Backing up and moving * Copy a table * CREATE TABLE NEW_TABLE SELECT * FROM OLD_TABLE ; * Copying distinct lines from a table * CREATE TABLE DISTINCT_METRICS AS (SELECT DISTINCT * FROM METRICS_JMALT);
E
dit
|
A
ttach
|
Watch
|
P
rint version
|
H
istory
: r4
<
r3
<
r2
<
r1
|
B
acklinks
|
V
iew topic
|
Ra
w
edit
|
M
ore topic actions
Topic revision: r4 - 2010-11-09
-
FrankHutter
Home
Site map
BETA web
Communications web
Faculty web
Imager web
LCI web
Main web
SPL web
Sandbox web
TWiki web
TestCases web
BETA Web
Create New Topic
Index
Search
Changes
Notifications
RSS Feed
Statistics
Preferences
P
View
Raw View
Print version
Find backlinks
History
More topic actions
Edit
Raw edit
Attach file or image
Edit topic preference settings
Set new parent
More topic actions
Account
Log In
Register User
E
dit
A
ttach
Copyright © 2008-2025 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback