[how to] How to update a table by count from another table? |
- How to update a table by count from another table?
- Multiple values for unique id?
- Database with 3 columns or 20 columns?
- How do I query a table with many trees of data, for one tree?
- Is it possible to disable replication for a specific database in RDS?
- show innodb engine status tuning db server
- Restore Huge Mysql database file
- Getting distinct list of records based on the MAX of a column
- SQL server 2008 enterprise RESEED to 0 anormally
- database table schema help reservation to items to products
- How to optimize this query more?
- How to Restore Emails from Exchange Server 2007 [on hold]
- Drop an index in postgresql
- Table redirect / filter / trigger on select
- Modeling a database for easy counting / reporting
- Putting a Select statement in a transaction
- Replication randomly started failing
- Problem compiling view when it is referencing a table in an other view: insufficient privileges
- CONNECT BY using 3 tables(2 DIM and 1 FACT to get the Level and dependencies)
- Connect Apache Http server with Oracle
- representation in ms-access
- PostgreSQL: DBLink weird permission/connection error
- How to setup SQL active/active cluster to achieve Blue / Green instance switching?
- Time series data for ad platform
- If an account has REQUIRE SUBJECT, does it still need a password?
- Install MariaDB without password prompt in ubuntu
- Converting dbo file from windows to linux
- How to change page size in an existing sybase database
- MySQL : Why are there "test" entries in mysql.db?
How to update a table by count from another table? Posted: 14 Sep 2013 07:55 PM PDT I have two tables as I want to search for the occurrence of each country in the How can I reduce the number of subqueries, and count all values in one subquery, then updating all columns? |
Multiple values for unique id? Posted: 14 Sep 2013 08:08 PM PDT I have two tables: customer and boxes in one-to-many relationship. The structure of the tables is in addition : The id of the boxes table is foreign key to the customer table. What if John has purchased more than 4 big boxes ? For example: he has ordered 2small boxes as well. How to add this to the database design schema? |
Database with 3 columns or 20 columns? Posted: 14 Sep 2013 05:49 PM PDT I have a database containing client informations. Every client is described by 20 fields A1, ... A20 containing a numeric value. Currently, the database has the following structure Ideally, I should reshape it in the following way However, there is a problem : with the time, some fields A1...A20 will become obsolete and I will add new fields. Hence, in 3 years I may end up with 40 columns instead of 20. Is it still a wise idea to reshape the database with (at least now) 20 columns ? |
How do I query a table with many trees of data, for one tree? Posted: 14 Sep 2013 03:16 PM PDT I have a the NAICS schema loaded and all is working well. However I'm confused as how I'd query it in Postgrseql? The table looks something like this, This is what I've wrote, This produces output like this (be sure to scroll to the end) However, what I want is to see one tree, so I can write a query like, And, get a tableset back as if the table was only preloaded with the parents of the supplied NAICS12 code. Any idea on how on further manipulate the data to get this kind of result out? |
Is it possible to disable replication for a specific database in RDS? Posted: 14 Sep 2013 10:48 AM PDT My application uses a mechanism of SQL patches as part of the upgrade to a new version. Before running an upgrade, I need to try to run the SQL patches on a copy of the database to ensure they complete without error, before running them on the actual db. I can do it on RDS, by creating a temporary DB, running the patches on it, and dropping it thereafter. But ideally, I'd want to do so without having the temporary database written to the binlog for backup and replication. Is it possible to mark a specific database as non-replicated in an RDS instance? My other option is to create a temporary RDS instance just for testing the upgrade, but that's a bit overkill and takes extra time to complete. |
show innodb engine status tuning db server Posted: 14 Sep 2013 10:24 AM PDT I am new to dealing with the innodb engine status. I am not too sure with I/O section. As below is sample of my output. I also notice a number of Why is it having so many transaction not started? What else can I look from this show engine to tune my db server? |
Restore Huge Mysql database file Posted: 14 Sep 2013 10:19 AM PDT i am trying to restore 18 G.B Mysql .sql database file in linux server what is the values should be in /etc/my.cnf in file so may increase the fast restoration |
Getting distinct list of records based on the MAX of a column Posted: 14 Sep 2013 01:27 PM PDT I have a status table (tblTestActionStatus) which has three columns ID_TestAction: references some test action ID_Status: a look up table reference for the variety of possible statuses for the action StatusDateTime: a datetime field which logs the exact time a status update was made for the test action. So while a test action is happening, periodic status updates are made. I am interested to know the current status which would be the last status update of a test action as of the moment I run the query. For example, test action # 100 has gotten 4 status changes so far. The first was 1, then 2, then 3, and most recently 4. And test action # 101 has gotten 3 status updates so far. So I would like to write a query that returns for me all the columns in the table but for only the most recent StatusDateTimes. I attached a pic which shows the table contents and the rows I would like to see coming back from the query highlighted. I was able to find an answer with some more searching in the archive. http://stackoverflow.com/questions/1049702/create-a-sql-query-to-retrieve-most-recent-records So the SQL I created from that post which works in my case is as follows... |
SQL server 2008 enterprise RESEED to 0 anormally Posted: 14 Sep 2013 09:29 AM PDT I am using EF 5.0, and sometimes no one can register on server by same error, PK PK_Invalid, and the PK is AUTO INCREMENT, this jumped 1000 to 10000 sometimes, but now this reseting to 0 and try subscribe a exists id. Why? How prevent? NOTE To fix I am using DBCC CHECKIDENT (User, reseed, 1080002). |
database table schema help reservation to items to products Posted: 14 Sep 2013 09:23 AM PDT I'm trying to get a decent structure for a database for an app and want to ensure I'm using best practice and get the right relationships. I'm not sure if I have a one to many relationship or a many to many... I have a table 'reservations' that receives reservations. I have another table called 'Items' that stores products ordered that belong to the reservation and includes options, qty etc. So assumed the relationship between reservation and items is a one to many. I then have another table called Products which has specifics about the items available. I've assumed this has a one to one relationship with Items. Is this the best approach to use or are there better ways I should learn/study. Are my understanding of the relationships correct or is the 'items' table simply a link table for a many to many relationship between reservation and products advice on approach and best practice appreciated database is a mysql Thanks |
How to optimize this query more? Posted: 14 Sep 2013 07:39 AM PDT First at all I am nood into SQL thing, Now I am working on a class project where I have some tables like Table user Table Friend Table Follow Table post Now I want to get post by users friend and who he follows and offcourse his so I made this SQL this query works just fine. I just wanted to know is there anymore optimization could be done? Then how? |
How to Restore Emails from Exchange Server 2007 [on hold] Posted: 14 Sep 2013 07:42 AM PDT My Exchange server 2007 database get corrupt and now i am unable to read EDB files emails, Please suggest me solution. Thanks |
Posted: 14 Sep 2013 07:33 PM PDT I had created an index wrongly and now im trying to drop that index. Since the datas are large for my table, dropping index is taking lot of time. Is there any other way to drop the index quickly? Thanks, Karthika |
Table redirect / filter / trigger on select Posted: 14 Sep 2013 09:20 AM PDT Is there any way to redirect queries to different tables / views based on the package that's referencing the table? I.e. packages A and B both have "select grade from schema1.grd_tbl", but I want package A to get the percent grade that's stored in the table, and package B to get a letter grade that's calculated from the percent. I'd like to avoid modifying the (dozens of) packages that reference the table. I'd rather 'spoof' the table somehow if we can, replacing the percent in the grade column with a letter when called from those packages. (The column's varchar2; percents are coded as characters.) First thought was to create a synonym pointing to a view that massages the column based on the calling package, but the code fully qualifies the table name in most cases so that doesn't seem doable. I went looking for something equivalent to a trigger on select; the closest I've found is fine-grained audit, and it's not row-based. Is there magic somewhere that might let me do this? Any hints appreciated. Perry. |
Modeling a database for easy counting / reporting Posted: 14 Sep 2013 08:20 PM PDT I have an app where user is known (user_id) and he can do several actions (action_id). Every time he makes an action I need to save the fact that he made it for reports/analytics. I guess it is similar to other analytic solutions and their db design. Once I have the data, provided with a time window (minutes resolution) I need to count for each user (all or some) the number of times he did actions and which actions he did. (sum all data grouped by action_id). Some assumptions:
I'm considering SQL, NoSQL and RRD to save the data. I put RRD here because it's easy to implement the insert of the data into statds+graphite. I'm concerned if I take this approach, the querying (although provided by graphite) will not be indexed and will probably have to count all the data whenever I ask for a window/user (no indexing). Another problem is that when querying all the data, all users info will be needed, resulting in reading all the files concurrently which I'm not sure is a good thing. SQL - Very easy implementation when inserting the data and querying. Easy to index, order and group by. However I'm not sure it's easy if I'm anticipating high traffic. Also, I'm not sure how effective is the count() of sql (haven't used SQL in the last few years) after group by. Can it offer parallel computation? NoSQL - Is there a solution out there that is the right fit for this type of scenario (perhaps a Map/Reduce algorithm to fast generation of counts in a time window?) Thanks for helping me model |
Putting a Select statement in a transaction Posted: 14 Sep 2013 01:20 PM PDT What is the difference between these 2 queries: And without transaction: What is the effect of having a If |
Replication randomly started failing Posted: 14 Sep 2013 08:20 AM PDT I have replication set up between two servers. This morning I came in and it was failing. I was getting these errors:
|
Problem compiling view when it is referencing a table in an other view: insufficient privileges Posted: 14 Sep 2013 11:20 AM PDT Oracle 11g R2 Logged on: SYS / AS SYSDBA When I try to compile or create a view that is referencing local schema tables. It works fine. Problem does occur when I try to compile the same view referencing a table in another schema like schema.table in my query. Oracle throws the exception ORA-01031: insufficient privileges. Remember I am using SYS account (sysdba). |
CONNECT BY using 3 tables(2 DIM and 1 FACT to get the Level and dependencies) Posted: 14 Sep 2013 05:20 AM PDT Below is my scenario and any help in this regard would be highly appreciated. I need to get the list of Managers and reporting persons to that manager with LEVEL at ID level. But the Fact table doesnt have hierarchial relationship with itself. Needs to get the id's from key's from 2 different dimension tables to generate the list. I am not familiar with CONNECT_BY and JOINS to get list. Fact table: In DIM Person table In DIM Manger table In the above scenario, |
Connect Apache Http server with Oracle Posted: 14 Sep 2013 06:20 AM PDT I have problem with connect ApacheHttpServer with Oracle. All work on OpenSuse 12.3 At first I install Oracle instal client 11.2. Set environment variables: After that I compile apache http : Unfortunately, the installation was not successful because mod_dbd_oracle.so didn't created. I think I was connected with that: I could not find a way how to solve. So I decided to use Oracle with ODBC driver. I install unixODBC 2.2.12-219.1.1. After that I modife to odbc.ini and odbcinst.ini: I chcek how it work with command: All was OK. So I again compile Apache Http Source. Modify httpd.conf to use ODBC: Start Apache HTTTP Server and I found in error logs: I don't know what I can do with that. Any suggestions would be very helpful. Maybe there is another way that conduct authorization and authentication using the Oracle database. Or other Apache module? |
Posted: 14 Sep 2013 07:20 PM PDT I have a database in microsoft access. I want to know how to look up a singular datum from a reference table giving a dynamic set of values. Here is a representation of what I mean: I have the following tables: Points for Pushups(m): Fitness Tests: People: I want the query to use People.DOB and the Test date to find the age the person was during the test. I then want the query to use this value to determine which column to look in, and the value from reps to determine which row to look in coming back with the singular value and naming it points. for example I want bob to show Query: Does anyone know how to do the dynamic reference part? I know how to make the query and I know how to get age I just don't know how to use the values as columns in the reference table, I've seen it done, but long ago and never looked into it. |
PostgreSQL: DBLink weird permission/connection error Posted: 14 Sep 2013 07:40 PM PDT The goal is to (1) create a connection, (2) return a view of another database, and (3) close the same connection all to be stored in a view (no stored procedure or embedded password). I came up with the following code, which uses a trust account and seems to work, until filtering on a boolean field. Searching for It's really odd that the data is being returned w/o needing the password, but when filtering, that is when the password is required. PostgreSQL: v8.4:
From within db_local (as md5_user): What works:
What doesn't work:
Filtering inside the second query works, but it doesn't help when wanting to store this in a view. I suppose I'm looking for suggestions, but really trying to understand what is going on eg. why searching for |
How to setup SQL active/active cluster to achieve Blue / Green instance switching? Posted: 14 Sep 2013 05:20 PM PDT I am wondering if anyone has ever used a multi-instance cluster (nee 'Active/Active') to achieve blue/green (or A/B) deployment scenarios, and what the best way of configuring it is (using SQL 2012 / Windows 2008 R2)? To be specific, the scenario I want to achieve is to be able to switch between which cluster instance is being connected to by clients without either the clients or the SQL instances knowing (I stress I'm not talking about node failover here). I'm envisaging that the best way to achieve this is something like:
This should hopefully enable me to do the following:
Joining the dots, it seems like this should be possible:
... but I've never seen a full example. Has anyone done it? Will what's proposed above work? What have I missed? |
Time series data for ad platform Posted: 14 Sep 2013 12:20 PM PDT I am trying to figure out how to store time series data for an ad platform I am working on. Basically I want to know some strategies/solutions for storing billions of rows of data so that I can easily search it (about 6-8 indexes on the table) and get fast counts based on queries. I tried mySQL with the tokuDB engine and this seems to be very fast but is extremely slow when I try to do a COUNT query when the rows reached about 5-8 million. I was looking at some noSQL alternatives but since I want to be able to search this data this is probably not the best solution. I was using dynamoDB. I would have had to store the data is many places in order to account for all the searching on the data. What I am storing is a row in the database for each click on an AD that occurs. This table will grow very fast, especially when this site gets large. Another solution would be to separate this data per advertiser. This means each advertiser will have their own table where all their data goes into. This means it will be much smaller and the COUNT queries will be much faster. I can even split it up by advertiser and month. My goal is to give an advertiser the ability to search and display in a paginated way all their clicks. They should be able to get data between a time period and filter by about 5-8 other indexes if they want to. |
If an account has REQUIRE SUBJECT, does it still need a password? Posted: 14 Sep 2013 06:20 PM PDT I'm in the process of setting up SSL-secured replication between two servers. Each server has its own public/private keypair, and the CA cert is just the concatenation of the two public certs, like this answer. Now I'm updating the replication account with REQUIRE SUBJECT "exact subject of the client" Is there any practical value to also having a password on the replication account (IDENTIFIED BY "secret")? |
Install MariaDB without password prompt in ubuntu Posted: 14 Sep 2013 07:41 AM PDT I need to install mariadb server in ubuntu without passwod prompt. For this purpose, I execute the following commands, but it doesn't gave me any progress. It again shows password prompt. I used the following commands : I also check some links in stack overflow, but it doesnot worked: http://stackoverflow.com/questions/7739645/install-mysql-on-ubuntu-without-password-prompt Please help me on this regard. Have any wrong with my code? |
Converting dbo file from windows to linux Posted: 14 Sep 2013 10:20 AM PDT I have a .dbo file which is created from windows. This file is succesfully reloaded into the mysql database in windows. I need to reload the dbo file into the mysql/mariadb database in linux. How I convert the file that was created from windows to linux? |
How to change page size in an existing sybase database Posted: 14 Sep 2013 07:20 AM PDT I have an existing database with 1 kb page size i want to increase that to 16kb and increase cache to take advantage of my memory for best performance. sybase documentations said you can't change page size of database but you can create new empty database with preferred page size, so how can i move my data to from old db to new database with big page size ? |
MySQL : Why are there "test" entries in mysql.db? Posted: 14 Sep 2013 05:05 PM PDT Recently, I posted an answer to a question about mysql.db. Then, I got to thinking I should ask everyone this question: I have noticed for years that upon installation of MySQL 5.0+, You can see it by running this query: Are these entries in the UPDATE 2013-06-14 10:13 EDTThis morning someone downvoted my question, which I truly don't understand. In light of this event, here is why I took the time to make a rebuttal: I installed MySQL 5.6.12 for a client this week in their Staging Cluster. I decided to check to see if this was still an on-going problem: Guess what? This is still a problem even to this day !!!MORAL OF THE STORY : Please check your |
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