[how to] Prune unused joins |
- Prune unused joins
- Does the week day number changes according to localization in SQL Server?
- Convert the table PROCESSLIST from InnoDB to MYISAM
- How to compare an attribute value of one table to all attribute values of another table?
- Automated query log
- How to/advice for hosting a multi-user database on the cloud with specific objectives
- How can extract the table schema from just the .frm file?
- App can't find or connect to database
- Is there a way, in a single SQL statement to ensure that all items in a list are present in some column?
- Combining multiple queries
- Multiple table rows in one row
- How to partition a very large table?
- MySQL Dumped data not displayed
- Backup not creating a new file
- Database Mail sending functionality not working on local system
- In the Vertica database, what is a namespace?
- createdb: could not connect to database postgres: FATAL: could not write init file
- Repeated values in group_concat
- Moving one TempdB on 3 instance server
- MySQL PDO Cannot assign requested address
- Alternative tools to export Oracle database to SQL Server?
- Performing SELECT on EACH ROW in CTE or Nested QUERY?
- List all permissions for a given role?
- Named Pipe Provider Error code 40
- ERWIN create and use database
- Restore SQL Server 2012 backup to a SQL Server 2008 database?
- How to recover MySQL table structure from FRM files
- INFORMATION_SCHEMA Selection Error
- Moving tables to another SQL2008 database (including indexes, triggers, etc.)
Posted: 11 Jun 2013 08:49 PM PDT I have expected that selecting from a view would not join the tables from which I don't query any values, but it doesn't seem to be the case. I have a bunch of tables with the following structure: There is also Now I create a view to show all entries for a given year: However, when selecting only the columns The entire code is in this gist. How do I tell the optimizer to avoid the useless joins? (Using PostgreSQL 8.4) EDIT: The error persists even when dropping the time dimension, see option1.sql in the gist. |
Does the week day number changes according to localization in SQL Server? Posted: 11 Jun 2013 03:27 PM PDT Does the weekday number changes according to server/database regional configuration in SQL Server (2005+)? |
Convert the table PROCESSLIST from InnoDB to MYISAM Posted: 11 Jun 2013 09:27 PM PDT I use MySQL. My database's name is "db", and I have a table called "Test". I want recover the last update, so I used this query: But the result is NULL, so I converted my Table from InnoDB to MYISAM by using this query: and it worked. But the problem is that when I want to convert the table PROCESSLIST from InnoDB to MYISAM I get this message: So, is there another solution to know what is the last update for this table (PROCESSLIST)? |
How to compare an attribute value of one table to all attribute values of another table? Posted: 11 Jun 2013 09:29 PM PDT I want to get all values of Can anybody help me with this one? |
Posted: 11 Jun 2013 06:43 PM PDT I would like to ask for some opinions or recommendations or guidelines on how to create an automatic logging system for the executed querys on a MySQL database. Some details:
I am familiar with TRIGGERS and STORED PROCEDURES, but cant really figure out if that's the the way, and if yes how (don't need code, just pure logic, although a usable minimalistic example would be welcomed). Thank you. |
How to/advice for hosting a multi-user database on the cloud with specific objectives Posted: 11 Jun 2013 11:03 AM PDT I have developed an application that users will be able to download and create an account with through our company. This application will always be connected to the internet. I have been testing the application with a local SQL database up to this point, but our goal is to have the database hosted online and I need to start thinking big picture. I have come up with a couple solutions, I would just like to here some input/advice from someone who is more experienced in the database world. Here is the problem: Our users sell products and we are an order manager. The tables that are going to have lots of entries will be Orders, Shipments, Archived Orders, Archived Shipments, etc. (especially for large companies that have thousands of daily orders.) I am trying to decide the best way to organize the tables/database to accommodate the growth our company will receive once the product is released (a couple hundred customers, a couple thousand in a couple years, not unlikely.) Just off the top of my head, I have a couple ideas: 1) One large Orders table, one large Shipments table. These tables store the thousands of orders/shipments that are added daily, they can be queried based off some company index. These tables will obviously get large (hundreds of customers adding thousands of orders/shipments daily) 2) Individual Orders and Shipments tables for each customer. So the name of the table would essentially be the organizer for different companies orders/shipments. Is this a logical answer for a situation like this? 3) Some sort of system where say the first X customers orders/shipments are added to one database's tables, and then when we get more than X customers, another database/server would be created to divvy up the server power/storage. Obviously you can tell I am not an expert and some of my questions may seem vague, but all I am looking for is some advice/possible solutions to move forward and start integrating my application with databases/servers on the cloud with the mindset that many customers will be added in a small period of time and I will need to approprately divide/add resources/servers/tables. Any input is appreciated. |
How can extract the table schema from just the .frm file? Posted: 11 Jun 2013 11:03 AM PDT I have extracted the data directory of mysql from a backup and need to get the schema from an old table, however it's a backup from a different machine. I have read a fair number of tutorials today on how to do this, but each time it seems to fail or I end up having to reinstall mysql because mysql hangs or crashes. (Create a different database, create table with same name, replace file, stop/start engine, recover from frm. Tried in varying orders and combinations.) Is there any external tool that can extract the schema from the .frm file? I can see the column names if I open up the file. I had a look but I can't seem to find anything that will enable me to do this. Thanks in advance. |
App can't find or connect to database Posted: 11 Jun 2013 10:55 AM PDT I'm trying to install a web app on my Ubuntu 12.04 server. The app is based on PHP and MySQL and I've got LAMP already working OK on my server - infact I've already got other apps working on PHP & MySQL already installed and working OK. The problem I'm facing is, that when I try to run this app I get the error
I have double and triple checked the username and password that I've put into the database.php and have confirmed that it's the same login credentials as what I use for phpMyAdmin and I'm even referring to the correct database (which as can be seen in phpMyAdmin, has been setup correctly. For the install, I have followed the instructions at http://sourceforge.net/p/coopos/wiki/Install/ The only place I have differed is, "Step III. Configure the Virtual Host" - reason being, I cannot move from "/var/www" to "/home/username/public_html" as I already have other apps running under "/var/www" My installation of the app (with all the error messages) can be seen at Would really appreciate some help on this, pls. |
Posted: 11 Jun 2013 01:01 PM PDT What I'm looking for is a way of verifying that all of a list of items (let's say 'FOO', 'BAR' and 'BAZ') are all in a given table.column. This would be something like SELECT something FROM sometable WHERE somevalue IN ('THIS', 'THAT', 'OTHER THING') ... except it's sort of the inverse: Ideally the statement would give me everything from ('FOO', 'BAR', 'BAZ') NOT IN sometable.somecolumn then I could use that as my check (assert that my SQL query returns an empty set or take the resulting set and complain that each of these is an "unrecognized" key). (A brute force approach would be to insert all of the terms/tags/items into a temporary, single column table and perform a JOIN ON my actual table's column for the set of rows which are NOT IN it. I'm sure I'm missing some syntactic trick that'll seem obvious once I see an example. In this particular case my table structures are something like: ... but I'm simply trying to come up with a template for taking an arbitrary number of "tags" and ensure that all of them are valid entries the "tags.tag" column. (The application will have to support arbitrarily complex queries for subsets of these tags to return DISTINCT subsets of the items; but I want to raise an error on any non-existent tag before building the JOIN's WHERE expression). Obviously I could just loop over the tags doing a separate SELECT tag_id FROM tags where tag=? ... entailing numerous round trips to the database. But this seems silly when I could send all of them to some sort of query in a single statement. |
Posted: 11 Jun 2013 06:47 PM PDT I have 2 queries given below. Now I want to have one quey by combining the two queries so as to get the table with columns ( Query 1: Query 2: |
Multiple table rows in one row Posted: 11 Jun 2013 03:48 PM PDT I have a table from where want to get such classes where 3rd position candidate got more marks than difference of 1st and 2nd. I want to write a query to find similar situation in all classes. |
How to partition a very large table? Posted: 11 Jun 2013 01:16 PM PDT I have a very big table. I want to partition it, but I cannot. Database size: 1TB, Free space 200GB Table:
In order to partition it, I need to create a clustered index. But creating parition requires free space of the same size as the table, and I do not have extra 600GB. Are there any options how I partition this table? EDIT 1: I have tried copying data into separate table. However when I try to |
MySQL Dumped data not displayed Posted: 11 Jun 2013 01:06 PM PDT I am using MySQL 5.0.88. I imported 20 GB dump file in my local machine. After successful import i check my DB but there is no records on that. When I looked a data directory the ibdata1 file size is 30 GB. There is no other database inside the data directory. how to i get the dumped data. Edit by RolandoMySQLDBA Request #1 : Please run this query and post its output The output was Request #2 : Please run these queries and post their output Request #3 : Please run this query and post its output I need to see the top of the import file. Please run this in the OS and post its output Request #4 : Please show the mysqld process from the command line # ps -ef | grep mysqld | grep -v grep Request #5 : Please run this query as shown |
Backup not creating a new file Posted: 11 Jun 2013 11:23 AM PDT I run a daily backup of my database through command prompt: But the new backup replaces the previous backup. Please tell me what to change so that all backups will be stored on disk. |
Database Mail sending functionality not working on local system Posted: 11 Jun 2013 12:45 PM PDT I am using Database Mail functionality to send mail from a SQL Server 2008 database via following stored procedure execution: I have tried with my gmail account profile on my local system it's working properly but not with my company or outlook profile. Error message:
Reference What would be the problem? Thanks |
In the Vertica database, what is a namespace? Posted: 11 Jun 2013 10:29 AM PDT In the Vertica database, what does the term "namespace" mean? I have reviewed the entire Vertica documentation and cannot find what this means. |
createdb: could not connect to database postgres: FATAL: could not write init file Posted: 11 Jun 2013 07:26 PM PDT RedHat Enterprise Server 3.0 32 Bits psql (PostgreSQL) 8.2.3 user: postgres server is running: I had just created a new database cluster with initdb; but when I run createdb: any clues as to the cause and possible solutions to this problem? |
Repeated values in group_concat Posted: 11 Jun 2013 03:47 PM PDT I have two tables, first the table food and Second is Activity: For now I'm using the following query: Could you please help me, I need output in the below format: |
Moving one TempdB on 3 instance server Posted: 11 Jun 2013 08:53 PM PDT I have a large virtual SQL Server (Full 2008R2). I run 3 SQL instances and would like to relocate the TempdB database file to another location, splitting off from the TempdB log file. The trouble I am having is that, even though the query Do I have to restart the whole server to move this database? |
MySQL PDO Cannot assign requested address Posted: 11 Jun 2013 01:26 PM PDT Can someone help me with this error? I have a Server with a lot connections per second; out of about 100 Connections, a single one got this error. I've tried this recommendation from stackoverflow however it does not solve my problem. |
Alternative tools to export Oracle database to SQL Server? Posted: 11 Jun 2013 03:26 PM PDT I've got an Oracle database that I need to export (schema and data) to SQL Server. I am trying the Microsoft SQL Server Migration Assistant for Oracle, but it is horribly slow, grossly inefficient and very un-user-friendly, e.g. I was having problems connecting to the SQL Server DB during data migration - but it still spent ~5 minutes preparing all the data before attempting a connection to SQL Server, then when it failed, the 5 minutes of preparatory work were wasted. Right now, I'm just trying to connect to another Oracle DB using this tool, I left it overnight and came back this morning, and it's still stuck on 19% of "Loading objects..." And this is on a machine with a good 18GB RAM, of which maybe 8.5 GB currently in use. Task Manager shows me that Are there any other tools out there that can migrate an Oracle DB to SQL Server a little more efficiently? |
Performing SELECT on EACH ROW in CTE or Nested QUERY? Posted: 11 Jun 2013 06:19 PM PDT This is a problem in PostgreSQL I have a table which stores the tree of users; +------+---------+ | id | parent | |------+---------| | 1 | 0 | |------|---------| | 2 | 1 | |------|---------| | 3 | 1 | |------|---------| | 4 | 2 | |------|---------| | 5 | 2 | |------|---------| | 6 | 4 | |------|---------| | 7 | 6 | |------|---------| | 8 | 6 | +------+---------+ I can query a complete tree from any node by using the connectby function, and I can separately query the size of tree in terms of total nodes in it, for example
Now I want to do something like Selecting all possible trees from this table (which is again carried out by connectby), count the size of it and create another dataset with records of ID and size of underlying tree, like this: +------------------+-------------+ | tree_root_node | tree_size | |------------------+-------------| | 1 | 7 | |------------------+-------------| | 2 | 3 | |------------------+-------------| | 3 | 0 | |------------------+-------------| | 4 | 3 | |------------------+-------------| | 5 | 0 | |------------------+-------------| | 6 | 2 | |------------------+-------------| | 7 | 0 | |------------------+-------------| | 8 | 0 | +------------------+-------------+ The problem is, I am unable to perform the same SELECT statement for every available row in original table in order to fetch the tree and calculate the size, and even if I could, I dont know how to create a separate dataset using the fetched and calculated data. I am not sure if this could be simple use of some functions available in Postgres or I'd have to write a function for it or simply I dont know what exactly is this kind of query is called but googling for hours and searching for another hour over here at dba.stackexchange returned nothing. Can someone please point to right direction ? |
List all permissions for a given role? Posted: 11 Jun 2013 08:09 PM PDT I've searched around all over and haven't found a conclusive answer to this question. I need a script that can give ALL permissions for an associated role. Any thoughts, or is it even possible? This gets me CLOSE - but I can't seem to flip it around and give the summary for roles, rather than users. |
Named Pipe Provider Error code 40 Posted: 11 Jun 2013 06:26 PM PDT I have literally tried everything, from enabling named pipe to adding exception to ports in the firewall, to everything possible in surface configuration. I can connect to the SQL instance(using TCP and Named Pipes) with SQL Server Management Studio. But Help! |
Posted: 11 Jun 2013 11:29 AM PDT Im trying to generate physical database from my logical model using ERWIN 7. All is well in the script that is generated automatically, there is only the problem that the model is created in the database "master" which is the default SQL Server, rather than being created in the database that I inserted along with the model. I cant find a way to associate my MODEL with the database im creating along with the model. Here is the script that ERWIN auto-generates: BUT it should generate automatically: Any ideas? |
Restore SQL Server 2012 backup to a SQL Server 2008 database? Posted: 11 Jun 2013 08:23 PM PDT Is there a way to restore a SQL Server 2012 database backup to a SQL Server 2008? I tried to attach file, it does not work. |
How to recover MySQL table structure from FRM files Posted: 11 Jun 2013 03:48 PM PDT What I have learned from Google searching: With MyISAM tables you can simply copy the FRM, MYD, and MYI files. In the folder for the DB I'm trying to recover, there are only FRM files and a "db.opt" file, so they must not be MyISAM tables. Situation: My computer crashed, but the data is still on the hard drive. The MySQL 5.5.8 server was installed with WAMP on the crashed computer. I have tried copying the entire data folder over, but MySQL only creates a blank database - no tables. There is an FRM file for each of the tables I wish to recover. However, they are not readable text files. Is there any way to recover the table structure from these files? This post http://stackoverflow.com/a/7688688/1188138 indicates that the structure is in fact in those files, but does not provide a method of retrieval. Thank you so much - I have tried everything I can think of. |
INFORMATION_SCHEMA Selection Error Posted: 11 Jun 2013 02:17 PM PDT I'm trying to select data from |
Moving tables to another SQL2008 database (including indexes, triggers, etc.) Posted: 11 Jun 2013 09:17 AM PDT I need to move a whole bunch (100+) of large (millions of rows) tables from one SQL2008 database to another. I originally just used the Import/Export Wizard, but all the destination tables were missing primary and foreign keys, indexes, constraints, triggers, etc. (Identity columns were also converted to plain INTs, but I think I just missed a checkbox in the wizard.) What's the right way to do this? If this were just a couple of tables, I would go back to the source, script out the table definition (with all indexes, etc), then run the index creation portions of the script on the destination. But with so many tables, this seems impractical. If there wasn't quite so much data, I could use the "Create Scripts..." wizard to script out the source, including data, but a 72m row script just doesn't seem like a good idea! |
You are subscribed to email updates from Recent Questions - Database Administrators Stack Exchange To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google Inc., 20 West Kinzie, Chicago IL USA 60610 |
No comments:
Post a Comment