mysql

Update scripts with workbench?

Currently I export the old database, search and replace the database names and do:] File -> Export -> SQL Alter script But first is there a way to avoid the database names? As my live database is likely to have a different name then in workbench. Second I encounter many times that the script tries to add foreign keys, but these will t...

How to convert MySQL to SQL Azure? ( Wordpress database )

How to convert MySQL to SQL Azure? I have a Wordpress site, and I would like to put it to Azure Platform. How can I achieve it? It seems not easy. Any shortcut? ...

search a database

Let's say I have a large database with product information. I want to create a search engine for that database, preferably with indexing and autocorrect features. How do I go about doing this? Are there any good libraries I could use, so that I don't have to start from scratch with basic SQL? Just some basic recommendations, links, would...

partial restore from sql dump?

I have a table that has 7000 rows, I added a new column to this table The table has a mysql DateTime so. When i updated the table to fill in this new table it updated the datetime, I took an sql dump just before i did the update so now i need to use the sql dump to revert the datetime back (and only that column). How do i do that? ...

MySQL InnoDB unlock a row

I get a lock timeout when updating a certain row in the database. Other rows update okay. #1205 - Lock wait timeout exceeded; try restarting transaction How can I unlock this particular row? Here are the two related tables. I'm trying to update the email on user. I don't think tenant should be causing any problems though. CREATE TA...

MySQL - using String as Primary Key

I saw a similar post on Stack Overflow already, but wasn't quite satisfied. Let's say I offer a Web service. http://foo.com/SERVICEID SERVICEID is a unique String ID used to reference the service (base 64, lower/uppercase + numbers), similar to how URL shortener services generate ID's for a URL. I understand that there are inherent pe...

how to use IGNORE?

i have mysql code for input data: $sql = "INSERT IGNORE INTO inspection_report "; $sql.= "(Model, Serial_number, Line, Shift, Inspection_datetime, Range_sampling, Packing, "; $sql.= "Accesories, Appearance, Tuner, General_operation, Class, Status, Remark, "; ...

Size for storing IPv4, IPv6 addresses as a string

what should be the ideal size for storing IPv4, IPv6 addresses as a string in the MySQL database. should varchar(32) be sufficient? ...

How many queries in one webpage?

How many queries in one webpage is good performance? If that page is home page that is viewed many times. and how about.... $sql1 = mysql_query("SELECT * FROM a", $db1); while($row = mysql_fetch_assoc($sql1)){ $sql2 = mysql_query("SELECT * FROM b WHERE aid='a'", $db2); $a = mysql_fetch_assoc($sql2); } is it good? acctually I can ...

benefit of calling mysql_close()

Possible Duplicates: using mysql_close() close mysql connection important? What are the benefits of closing the connection using mysql_close() as the last line of your script compared to letting php close it for you? ...

MySQL - how to use VARCHAR as AUTO INCREMENT Primary Key

I am using a VARCHAR as my primary key. I want to auto increment it (base 62, lower/upper case, numbers), However, the below code fails (for obvious reasons): CREATE TABLE IF NOT EXISTS `campaign` ( `account_id` BIGINT(20) NOT NULL, `type` SMALLINT(5) NOT NULL, `id` VARCHAR(16) NOT NULL AUTO_INCREMENT PRIMARY KEY ) ENGINE=MyISAM ...

PHP round off to the nearest 10 ?

I have a data like 93 i want if to become 90 95 i want to become 100 How can I do that in PHP? Thanks! ...

Better site performance: multiple simple mySQL queries or one complex mySQL query later manipulated in PHP?

I am new to web development and am used to extensive use of various data structures in getting things done. I've also heard that having lots of queries is worse than few queries (but that complex queries can be even slower). I'm wondering whether lots of simple queries would perform better or worse than one complex query that is later p...

To separate to a different table or use enum type?

I'm working with an online shop, currently products are either available or not, and enabled or not, by an int field on the products table. They want me to add more to this, e.g. "in stock with supplier", "out of stock, ships within x days" etc. I'm thinking of just ditching the flags and creating a status field of enum type, with 'ava...

MYSQL alter table - add INDEX + FOREIGN KEY give error 1005

what is wrong with this alter table command : ALTER TABLE `lp` ADD COLUMN `RuleId` INT(10) NOT NULL DEFAULT -111 AFTER `Weight` , , ADD CONSTRAINT `fk_1` FOREIGN KEY (`RuleId` ) REFERENCES `Rules` (`RuleId` ) ON DELETE NO ACTION ON UPDATE NO ACTION, ADD INDEX `fk_1` (`RuleId` ASC) ; if i drop the line ADD CONSTRAINT `fk_1` FORE...

How to migrate SQL Server 2008 to MySQL 5.0 programmaticaly? {Closed}

How to migrate sql server 2008 to my sql 5.0 programmatically? any link? EDit:- Sorry for not asking question properly,See we will be getting sql server backup from client every night,and we have to load it to my sql every night.so we my solution is t0 try transtional replication.so i am trying heterogenous subscriber as my sql and prov...

Is there a way to force MySQL execution order?

I know I can change the way MySQL executes a query by using the FORCE INDEX (abc) keyword. But is there a way to change the execution order? My query looks like this: SELECT c.* FROM table1 a INNER JOIN table2 b ON a.id = b.table1_id INNER JOIN table3 c ON b.itemid = c.itemid WHERE a.itemtype = 1 AND a.busy = 1 AND b.something = 0 ...

How to shrink/purge ibdata1 file in MySQL

I am using MySQL in localhost as a "query tool" for performing statistics in R, that is, everytime I run a R script, I create a new database (A), create a new table (B), import the data into B, submit a query to get what I need, and then I drop B and drop A. It's working fine for me, but I realize that the ibdata file size is increasing...

how to use UNIQUE index correctly?

i have 4 fields at DB.i set them become cant duplicate entry.They are: 1. Model Varchar(14) Unique 2. Serial varchar(8) Unique 3. Lot varchar(5) Unique 4. Line char(5) Unique Model Serial Lot Line First data remocon x0001 ...

Mysql Truncated incorrect DOUBLE value

When I execute this SQL query: UPDATE shop_category SET name = 'Secolul XVI - XVIII' AND name_eng = '16th to 18th centuries' WHERE category_id = 4768 I receive the following error: 1292 - Truncated incorrect DOUBLE value: 'Secolul XVI - XVIII' 'shop_category' table structure: category_id mediumint(8) name varchar(250) nam...