database-administration

How to monitor MySQL space?

北战南征 提交于 2019-12-20 09:07:13
问题 I downloaded a VM image of a web application that uses MySQL. How can I monitor its space consumption and know when additional space must be added? 回答1: I have some great big queries to share: Run this to get the Total MySQL Data and Index Usage By Storage Engine SELECT IFNULL(B.engine,'Total') "Storage Engine", CONCAT(LPAD(REPLACE(FORMAT(B.DSize/POWER(1024,pw),3),',',''),17,' '),' ', SUBSTR(' KMGTP',pw+1,1),'B') "Data Size", CONCAT(LPAD(REPLACE( FORMAT(B.ISize/POWER(1024,pw),3),',',''),17,'

How do I GRANT ALL PRIVILEGES on ALL VIEWS in one statement?

一个人想着一个人 提交于 2019-12-20 04:26:04
问题 In PostgreSQL 9+, is there a way to GRANT ALL PRIVILEGES on ALL VIEWS in schema schema_name TO role_name in a single statement? 回答1: The only way to do this in a single statement (kind of) is to create a function, otherwise you are either specifically listing all views or you are granting to all tables, then revoking non-views. I wrote this quickly, but tested it. You may need to tweak as needed: CREATE OR REPLACE FUNCTION fn_grant_all_views(schema_name TEXT, role_name TEXT) RETURNS VOID AS

Why many tables ORACLE default 12c?

本小妞迷上赌 提交于 2019-12-20 02:49:24
问题 Creating a new database (basic and advanced), It's my first time dealing with Oracle, in which I do not know why so many tables, triggers, views and other objects when only wanted to create a relational data base empty. Is there another way to do this or is there something I missed understand? Thank you. Capture: 回答1: Those objects are owned by SYS user. You could verify it using following query: SELECT * FROM DBA_OBJECTS WHERE OWNER = 'SYS'; To see the objects owned by other users, see:

set new value for “ft_min_word_len ” FULLTEXT in mysql

余生颓废 提交于 2019-12-18 19:23:23
问题 I changed to "ft_min_word_len" = 4 by my-innodb-heavy-4G.ini located in my system path "C:\Program Files\MySQL\MySQL Server 5.1" , but when i run SHOW VARIABLES LIKE 'ft_min_word_len' I got still result value= 4 . I did not find this variable in my.ini file. So i have also create a my logic. I copied to ft_min_word_len variable and place in my.ini file and now my result show value=3 . But it is not working for three character search. I've restarted server. How can i achieve to be able to

Designing a SQL schema for a combination of many-to-many relationship (variations of products)

☆樱花仙子☆ 提交于 2019-12-17 17:33:10
问题 I hope the title is somewhat helpful. I'm using MySQL as my database I am building a database of products and am not sure how to handle storing prices/SKU of variations of a product. A product may have unlimited variations, and each variation combination has its own price/SKU/etc.. This is how I have my products/variations table set up at the moment: PRODUCTS +--------------------------+ | id | name | description | +----+------+--------------+ | 1 | rug | a cool rug | | 2 | cup | a coffee cup

Find out the history of SQL queries

ぃ、小莉子 提交于 2019-12-17 10:35:48
问题 An update SQL query was executed on the server, which caused many problems later. How can I get the list of update queries executed in last 2 months, so that I can trace the exact problematic SQL query? 回答1: select v.SQL_TEXT, v.PARSING_SCHEMA_NAME, v.FIRST_LOAD_TIME, v.DISK_READS, v.ROWS_PROCESSED, v.ELAPSED_TIME, v.service from v$sql v where to_date(v.FIRST_LOAD_TIME,'YYYY-MM-DD hh24:mi:ss')>ADD_MONTHS(trunc(sysdate,'MM'),-2) where clause is optional. You can sort the results according to

Frontend tool to manage H2 database [closed]

放肆的年华 提交于 2019-12-17 05:41:01
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . How to use H2 database's integrated managment frontend? For operations such as create table, alter table, add column, and so on. 回答1: I like SQuirreL SQL Client, and NetBeans is very useful; but more often, I just fire up the built-in org.h2.tools.Server and browse port 8082: $ java -cp /opt/h2/bin/h2.jar org.h2

Drop a role with privileges

我是研究僧i 提交于 2019-12-14 03:59:39
问题 This looks like a very basic need, but I do not find any quick and suitable answer. I have a role in Postgres which has privileges to many other tables in various databases. I need to drop this role. I have one postgres instance and then many databases on top of it. SELECT DISTINCT 'REVOKE ALL ON TABLE ' || table_schema || '.' || table_name || ' FROM ' || r.param_role_name || ';' FROM information_schema.table_privileges CROSS JOIN (SELECT 'some_role_name'::text AS param_role_name) r WHERE

How to use default schema privileges on functions in Postgres in right way?

笑着哭i 提交于 2019-12-13 17:25:59
问题 I am struggling to comprehend how default schema privileges work in Postgres. To me, they are something that supposed to ease administration load by issuing permissions automatically, but I found them bit unusable. I discovered several things that are not at all obvious from documentation. I want several users to be able to create and modify objects in schema. I create a role who gonna be the owner and grant this role to multiple (in general) users: create schema my_schema; create role my

in MySQL, is it good to have 500 Columns in one table?

一世执手 提交于 2019-12-13 08:35:19
问题 in MySQL, is it good to have 500 Columns in one table? the rows will be increasing daily, the maximum row count would be less than or equal to 1million. just to give a brief, these are my column headers TableName: process_detail id, process_id, item_id, item_category, attribute1,attribute2,attribute3,...,attribute500,user_id1_update_time,user_id2_update_time,user_id1_comments,user_id2_comments all attributes are varchar with length maximum 30. but less than 30. and i have 25 item_categories.