[how to] Declare variable mysql |
- Declare variable mysql
- Database schema for record belonging to another record or its sub-record
- Permissions different between test and live databases
- Syntax for restoring SQL Server backup from non-disk source
- Entering Images url faster in mysql database
- Best way set clustered primary key on a partitioned table?
- PostgreSQL Failover Issue
- Can't backup a Postgres database: FATAL: Peer authentication failed for user "postgres"
- Should I join datetime to a date using cast or range?
- I want sql code retrieves fields from different tables in Visual Basic2010
- Inserting two rows from single row
- PostgreSQL Cascade Delete not working
- Is there a general guideline for table partitioning? [on hold]
- Multi Server Query generating Login failures
- I want sql code retrieves fields from different tables? [on hold]
- Can this query be optimized further?
- MySQL performance for key value vs multiple columns [on hold]
- Duplicating database on the same server without data loss
- Should I create a table separately for each employee or one table for all? [duplicate]
- Postgres functions vs prepared queries
- Classifieds Database Design
- InnoDB Failure of some kind
- MySQL is running but not working
- Mistake during Oracle 11g PITR
- How can I convert an Oracle dump file into SQL Server?
- SQL Server LocalDB Instance; error restoring backup (MasterDBPath not available)
- Table not getting created under dbo schema
- No NULLs, yet invalid byte sequence for encoding "UTF8": 0x00
- Is it possible to restore sql-server bak and shrink the log at the same time?
Posted: 10 Oct 2013 09:11 PM PDT I am new to mysql, I have been using SQL in the past. I am trying to insert rows into a table via creating a loop. But struggling with it. Any help? DECLARE @minid INT = (SELECT MIN(Product_ID) FROM Product_Report_Offer_Interaction_Jan_2012 pn) DECLARE @maxid INT = (SELECT max(Product_ID) FROM Product_Report_Offer_Interaction_Jan_2012 pn) DECLARE @topid INT= @minid + 50000 BEGIN WHILE ( @minid < @maxid ) BEGIN insert into Product_Report_Offer_Jan_2012 (Month, Product_ID, Offerview, EnlargeImage, DynamicPopUp, ShareonFacebook, BuyNowPress, Sendtofriend, Printed, StoreLocated, uLike, iPhoneOfferDetails, iPhoneStoreLocated, WishlistAd, Tweet, Catalogue1pageview, Catalogue2pageview, SearchListing, Featured, RelatedAdImpression, Wishlist) select pn.Month, pn.Product_ID, pn.Offerview, pn.EnlargeImage, pn.DynamicPopUp, pn.ShareonFacebook, pn.BuyNowPress, pn.Sendtofriend, pn.Printed, pn.StoreLocated, pn.uLike, pn.iPhoneOfferDetails, pn.iPhoneStoreLocated, pn.WishlistAd, pn.Tweet, pm.Catalogue1pageview, pm.Catalogue2pageview, pm.SearchListing, pm.Featured, pm.RelatedAdImpression, pm.Wishlist -- select count(*) -- select * END END Thanks jakub |
Database schema for record belonging to another record or its sub-record Posted: 10 Oct 2013 06:22 PM PDT I have 2 tables; I'm trying to implement another table called In this case, the records for
Any comments or improvement for such a design? |
Permissions different between test and live databases Posted: 10 Oct 2013 05:22 PM PDT We have 2 database Servers - Test and Live. We restore the live database back to test periodically. We have noticed that a SQL User has access to execute a stored proc on live but not on the test database but we can't work out why there is a difference. (Note: The user should be able to execute the stored proc). We have looked in the users properties and they are all in the same groups, the groups look to be the same on both servers. However when I look at the Effective Permissions on a particular stored proc the user has permission to EXECUTE on live but not on Test: (Live on the left) How can I find out what is giving access for this user to have permission to Execute on Live? |
Syntax for restoring SQL Server backup from non-disk source Posted: 10 Oct 2013 05:06 PM PDT I have backed up and restored many a SQL Server database using T-SQL script, but always Now I'm working with a database new to me where the Unfortunately at this moment I don't have on-demand access to the server where the backup is and the server doesn't have enough disk space for an extra copy of the database, anyway. But, when I DO get in this situation again, I'd like to know the correct syntax.
Or is there some additional set of values I need from the |
Entering Images url faster in mysql database Posted: 10 Oct 2013 02:45 PM PDT First, I would like to say I dont have much experience with entering data into database so my wording might be a bit off. I'm working on adding products into my database for a shopping cart. I'm using OpenCart for the shopping cart. My question is how can I edit a large about of mysql fields without manually doing it. I have edited in all of the products information, like model id, manufacturer, and so on, but not the images because of how slow entering in the images are on OpenCart. So I'm wondering is their any way to import all of the images urls quickly. The images are uploaded to the server all I have to do is fill in the image field for each product. I have saved the product's images with the model id. for example one poducts model is 1194, so the image is 1194.jpg. I have also organized the images to match the manufacturer, and example would be data/manufacturer/1194.jpg. Now is there a way to quickly add all the urls and have the it read the model id and insert it into the url. like instert 'image' data/manufacturer/$model.jpg |
Best way set clustered primary key on a partitioned table? Posted: 10 Oct 2013 02:40 PM PDT I have the following table. The table will be partitioned by K1 (K1 has low selective. the data will be appended in the order by |
Posted: 10 Oct 2013 12:31 PM PDT I have 3 PostgreSQL (9.1) server's, 1 master and 2 slave. I have configured streaming replication between them. Now when i shutdown the primary server and convert one of the slave to act as primary ( using the trigger ), the recovery.conf is changed to recovery.done. Now my problem is while using rails application with postgres the replication works fine, But when there is change in primary i.e a slave is promoted to primary the rails app does not know that. What gem should I use to resolve this, so that the rails app will know the change in primary. And how should the config must be done. |
Can't backup a Postgres database: FATAL: Peer authentication failed for user "postgres" Posted: 10 Oct 2013 03:20 PM PDT I can connect to my database no problem remotely, either from PHP scripts on our webserver or using PGAdmin3. Unfortunately, when I try to run pg_dump backups locally on the server itself, I get:
Previously I'd had no password at all for my database, but to try to get around this I actually gave the postgres user a password. Still no dice, peer authentication fails every time. Here's the settings in my pg_hba.conf file... please tell me what I can do to fix this. Really want to run some backups on my database. |
Should I join datetime to a date using cast or range? Posted: 10 Oct 2013 12:29 PM PDT This question is a take-off from the excellent one posed here: Cast to date is sargable but is it a good idea? In my case, I am not concerned with the One table has My question is which is preferable? The I expect to stay on the order of 2M rows having the Should I expect the same behavior on the My generalized use-case is to treat my events table like a calendar table |
I want sql code retrieves fields from different tables in Visual Basic2010 Posted: 10 Oct 2013 11:21 AM PDT 0down votefavorite I want sql code retrieves fields from different tables in Visual Basic2010. Ihave four tables which like this: 1)tblTeacher consist of TID(pk),TName 2)tblSubject consist of SID(pk),subName,TID(fk),TMID(fk) 3)tblTime consist of TMID(pk),TMValue 4)tblLecture consist of LecID(pk),LecDate,TID(fk),subID(fk),TMID(fk) this table for registerd Lectures. there is a relation betwen tables(one to many) (tblLecture is many). and I want to offer LecID,LecDate,TName,subName,TMValue(which registered in tblLecture only) in DataGridView.(in my project I use access DataBase and sql can you use select statement?DataSourse,DataSet And TapleAdapter) and how I can call the sql in my project please? |
Inserting two rows from single row Posted: 10 Oct 2013 04:25 PM PDT I have to import users from the Here's how I'm doing it currently: http://sqlfiddle.com/#!6/c9b2e/1 (for some reason, it's not outputting anything, but the code works in SSMS). Is there a way to do this without using two different selects? Maybe self-joining |
PostgreSQL Cascade Delete not working Posted: 10 Oct 2013 11:49 AM PDT What am I missing here? I have two tables: source is the parent table and updates the child. I want any records deleted from source to cascade down and delete all records in updates that have the same sourceid. I have also tried adding the REFERENCES constraint to the sourceid field of the source table. Thanks! Brad |
Is there a general guideline for table partitioning? [on hold] Posted: 10 Oct 2013 02:00 PM PDT
What's the MMM, NNN, XXX or YYY values you choose? For example, if you have a table with size of 500GB, you probably definitely go partitioning. How about a table with 200M rows? Or a table with size of 5GB? |
Multi Server Query generating Login failures Posted: 10 Oct 2013 02:01 PM PDT My problem is that when using multi server queries using SSMS from SQL Server 2008 R2 against SQL Server 2005, SQL Server 2008R2 and SQL Server 2000 I occasionally get error messages such as: SQL Server 2008R2
SQL Server 2005
SQL Server 2000
Now my query works fine but given what my query does is search for errors in logs it is not ideal that it should also generate such errors. My methodology may be flawed, what I have done is create a group under Local Server Groups and registered a few dozen servers of various versions. Then I right click on this group, select New Query to open a new batch window. Lastly I open my saved script and run it. In rough outline this is what it does I am a sysadmin on all machines. Two things I tried was the 'use master' statement at the top of the script and changing the registered servers to have a "Connect to database" of master. Neither of these has eliminated the problem. Does anyone have any further suggestions? |
I want sql code retrieves fields from different tables? [on hold] Posted: 10 Oct 2013 10:37 AM PDT I want sql code retrieves fields from different tables in Visual Basic 2010. thankyou very much,Ihave four tables which like this: 1)tblTeacher consist of TID(pk),TName 2)tblSubject consist of SID(pk),subName,TID(fk),TMID(fk) 3)tblTime consist of TMID(pk),TMValue 4)tblLecture consist of LecID(pk),LecDate,TID(fk),subID(fk),TMID(fk) this table for registerd Lectures. there is a relation betwen tables(one to many) (tblLecture is many). and I want to offer LecID,LecDate,TName,subName,TMValue(which registered in tblLecture only) in DataGridView.(in my project I use access DataBase and sql can you use select statement?DataSourse,DataSet And TapleAdapter) and how I can call the sql in my project please? |
Can this query be optimized further? Posted: 10 Oct 2013 03:43 PM PDT I have 100K records in my This is my statistics output: SQL Server Execution Times: CPU time = 0 ms, elapsed time = 0 ms. and this is my query plan XML. All indexes are created properly. I am unable to post here due to body limit of 30K. https://www.dropbox.com/s/vrx5ec6cpi8vn33/plan.txt Any help would be appreciated. Thanks! |
MySQL performance for key value vs multiple columns [on hold] Posted: 10 Oct 2013 06:57 PM PDT For a key value store I will have 3 columns
Each For selecting, I will be doing For multiple columnsI have For selecting, I will be doing My question is performance-wise, which design would be better query performance when there are a lot of |
Duplicating database on the same server without data loss Posted: 10 Oct 2013 08:09 PM PDT I want to duplicate an innodb database on my mysql server for testing another version of the software. Just copying the folder under /var/lib/mysql won't work, because I didn't enabled something special for the innodb engine. How can I create a duplicate of an innodb database? |
Should I create a table separately for each employee or one table for all? [duplicate] Posted: 10 Oct 2013 11:42 AM PDT This question already has an answer here: I'm trying to figure out how to set up the Database structure. There are ~10000 employees.There will be a table to store the basic details of the employee, and another table for storing transactions of the employee, so I decided to create separate tables for all the employee to record their transactions, which means ~10000 tables. So my question is, is it efficient to create that much of tables(~10000), or any other approach you can suggest, I will be using MySQL as database and a Java client, in a LAN. |
Postgres functions vs prepared queries Posted: 10 Oct 2013 03:39 PM PDT I'm sure it's there but I've not been able to find a simple definitive answer to this in the docs or via Google: In Postgres, are prepared queries and user defined functions equivalent as a mechanism for guarding against SQL injection? Are there particular advantages in one approach over the other? Thanks |
Posted: 10 Oct 2013 10:25 AM PDT I have always worked with CMSs, but I am trying to get into using frameworks like Laravel and Yii. My main issue is when working with CMSs, I didn't have to think much about the database design since it was done for me. I have my plan drawn out on paper, but I am not really sure where to go from here.... I am trying to develop a Craigslist clone, but a little more specific. I have Googled all over for designs, and this is currently what I have. However, I want certain categories to have specific fields. Some categories may have fields in common with other categories, but not all categories are the same. For example: Those are just two examples, but I have a huge list of Categories and the required fields for each category. My current plan is to load all of these fields into the ad table. What effect will this have on performance? At some point there could be 60 fields attached to the ad table, but only 5-10 may be filled at a time, and the others would be empty/NULL. What is the best way to go about associating images with ads? I was thinking to just create an assets folder and create subfolders based on the ad id, and upload images to those subfolders of the corresponding ad id. Something like... What's the best way to set up this kind of database? Would sticking to MySQL be best for this? What if I want some states to have certain categories but not others? |
Posted: 10 Oct 2013 02:25 PM PDT I have MySQL 5.5 installed. I tried to install Joolma but it failed. I went into their sql and replace EGNINE=InnoDB with MyISAM and the install worked. InnoDB is listed under SHOW ENGINES; Any idea what the cause is or how to fix this so other InnoDB sites can be used? I had these errors: |
MySQL is running but not working Posted: 10 Oct 2013 04:26 PM PDT In an attempt to tune MySQL to make it work with a recent installation of Drupal I had to modify the MySQL settings on my server. After modifying the configuration file for MySQL (/etc/my.cnf) MySQL stopped working. After some attempts I make it start again but now all my php/MySQL webistes are not being able to connect to their DBs. Here is why is so confusing:
My websites using MySQL almost all say: Another say: This is my current my.cnf: I commented most of it to return it to its simplest version... How can I make the web side to connect to mysql? |
Mistake during Oracle 11g PITR Posted: 10 Oct 2013 12:25 PM PDT I tried using set time until.. and mis-typed the date. Can anyone help me understand how to get my backups into a manageable state? After the accidental recover, most of my backupset disappeared. I recovered them and used 'catalog recovery area' .. and they're listed in 'list backupset'. But something still isn't right. When I do a PITR now, I get messages that my dbf files aren't available and... the 'list backupset' seems to show backupsets. But they are listed differently than the files which weren't included in the 'bad' recovery. Gists with the error and the list of backupsets are here https://gist.github.com/akinsgre/5561254 |
How can I convert an Oracle dump file into SQL Server? Posted: 10 Oct 2013 12:58 PM PDT I want to ask about converting Oracle dump files ( I've searched for related technologies, such as Oradump to SQL Server. Do you have another suggestion to solve this? Open source ones I mean. Thanks for both of your response. I see how difficult it will, but is there any possibility to use another way in converting oracle dump file? because all of solution's converter tools always provide a connection database server. I'm so thankful what if you can suggest another tool. thanks anyway |
SQL Server LocalDB Instance; error restoring backup (MasterDBPath not available) Posted: 10 Oct 2013 04:34 PM PDT I have SQL Server 2012 Local DB Installed, and am connecting to it via (localdb)\v11.0. When trying to restore a backup file, I get:
I have tried setting MasterDBPath string value in: but this hasn't helped. Anyone have any thoughts? |
Table not getting created under dbo schema Posted: 10 Oct 2013 09:05 PM PDT When creating tables in SSMS, I've realized that if you execute the following statement: the table will be created under your own schema (and not dbo). So in order to create it under the dbo schema, you'll need to explicitly say so, like this: Does anyone know of a way (eg. server-wide setting) so that when a table is created, the [dbo] part doesn't need to be specified? |
No NULLs, yet invalid byte sequence for encoding "UTF8": 0x00 Posted: 10 Oct 2013 02:31 PM PDT I've spent the last 8 hours trying to import the output of 'mysqldump --compatible=postgresql' into PostgreSQL 8.4.9, and I've read at least 20 different threads here and elesewhere already about this specific problem, but found no real usable answer that works. MySQL 5.1.52 data dumped: PostgreSQL 8.4.9 server as destination Loading the data with 'psql -U rt_user -f foo' is reporting (many of these, here's one example): According the following, there are no NULL (0x00) characters in the input file. Likewise, another check with Perl shows no NULLs: As the "HINT" in the error mentions, I have tried every possible way to set 'client_encoding' to 'UTF8', and I succeed but it has no effect toward solving my problem. Perfect, yet: Barring the "According to Hoyle" correct answer, which would be fantastic to hear, and knowing that I really don't care about preserving any non-ASCII characters for this seldom-referenced data, what suggestions do you have? Update: I get the same error with an ASCII-only version of the same dump file at import time. Truly mind-boggling: One of the tables in question is defined as: I do not have the liberty to change the type for any part of the DB schema. Doing so would likely break future upgrades of the software, etc. The likely problem column is 'content' of type 'text' (perhaps others in other tables as well). As I already know from previous research, PostgreSQL will not allow NULL in 'text' values. However, please see above where both sed and Perl show no NULL characters, and then further down where I strip all non-ASCII characters from the entire dump file but it still barfs. |
Is it possible to restore sql-server bak and shrink the log at the same time? Posted: 10 Oct 2013 08:11 PM PDT We have a bak file from a client that we have transferred to our developer offices for problem investigation. The backup is currently 25GB and the restored database is about the same size however it needs 100GB to be restored. I believe this is because there database is set up to have a 75GB transaction log size. After restoring the database we can shrink the log file but is there a way to do this in the restore? |
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