Most Popular

1500 questions
59
votes
1 answer

What is the meaning of filtered in MySQL explain?

As described here in the MySQL docs: The filtered column indicates an estimated percentage of table rows that will be filtered by the table condition. That is, rows shows the estimated number of rows examined and rows × filtered / 100 shows the…
Iman Tumorang
  • 635
  • 1
  • 6
  • 12
59
votes
1 answer

Best practices for schema changes and data migrations to a live database without downtime?

How do you make schema changes to a live database without downtime? For instance, lets say I have a PostgreSQL database with a table including various user data like email addresses etc, all associated with specific users. If I wanted to move the…
Dan Leary
  • 693
  • 1
  • 6
  • 5
59
votes
6 answers

What problems will I get creating a database per customer?

I remember from the stackoverflow podcasts that Fog Creek use a database per customer for Fogbugz. I assume that means the Fogbugz On Demand servers have 10s of thousands of databases. We are just starting to develop a web app and have a similar…
Rik Heywood
  • 693
  • 1
  • 6
  • 6
59
votes
4 answers

How to check foreign keys related to a table

How to see foreign keys related to a table in MySql? Background : I wanted to drop a table in MySql which has a foreign key constraint. When I do it I get this: Error Code: 1217. Cannot delete or update a parent row: a foreign key constraint…
Zameer Ansari
  • 901
  • 1
  • 13
  • 19
58
votes
9 answers

Should you design the database before the application code is written?

What is the easiest and most efficient way to design a database? From my perspective, there are a couple of options for an application's data store design: Design the database as best as you can initially before writing any application code. This…
Thomas Stringer
  • 42,224
  • 9
  • 117
  • 154
58
votes
5 answers

What is a Key/Value store database?

I've been looking at the wikipedia page for NoSQL and it lists several variations on the Key/Value store database, but I can't find any details on what it means by Key/Value store in this context. Could someone explain or link an explanation to me?…
indyK1ng
  • 1,111
  • 1
  • 12
  • 11
58
votes
2 answers

MATCH FULL vs MATCH SIMPLE in foreign key constraints

I've noticed the clauses MATCH SIMPLE and MATCH FULL in phpPgAdmin, but I can't find a description in the docs. The default is MATCH SIMPLE. How do they function?
user32234
58
votes
6 answers

After moving database (backup, restore), I have to re-add user

I occasionally move a database (SQL Express 2012) from a development machine to a server, or vice versa, using database backup and restore in SQL Server Management Studio. Whenever I do this, the applications on the target machine cannot access the…
xpda
  • 765
  • 1
  • 6
  • 8
58
votes
7 answers

In what data type should I store an email address in database?

I understand that an 254 character email address is valid, but implementations I have researched tend to use a varchar(60) to varchar(80) or equivalent. For example: this SQL Server recommendation uses varchar(80) or this Oracle example Is there a…
Thronk
  • 1,388
  • 3
  • 19
  • 38
58
votes
3 answers

Possible INDEX on a VARCHAR field in MySql

I am working in a MySql database, with a table like this: +--------------+ | table_name | +--------------+ | myField | +--------------+ ...and I need to make a lot of queries like this (with 5-10 strings in the list): SELECT myField FROM…
Mark Tower
  • 683
  • 1
  • 6
  • 6
58
votes
1 answer

Size limit of character varying Postgresql

What is the size limit of various data types in postgresql? I saw somewhere that for character varying(n), varchar(n) n must be between 1 to 10485760. Is that true? What are the valid sizes for character(n), char(n) and text?
Fredy De La Cruz
  • 683
  • 1
  • 5
  • 4
58
votes
11 answers

Why aren't primary key / foreign key matches used for joins?

As far as I could find out many DBMSs (e.g. mysql, postgres, mssql) use fk and pk combinations only to constrain changes to data, but they are rarely natively used to automatically select columns to join (like natural join does with names). Why is…
Tiddo
  • 997
  • 2
  • 8
  • 11
58
votes
6 answers

What are the main causes of deadlocks and can they be prevented?

Recently one of our ASP.NET applications displayed a database deadlock error and I was requested to check and fix the error. I managed to find the cause of the deadlock was a stored procedure that was rigorously updating a table within a…
Sandeep Kumar M
  • 4,642
  • 3
  • 32
  • 35
58
votes
5 answers

Why is DROP DATABASE taking so long? (MySQL)

New CentOS installation. I was running an import of a large DB (2GB sql file) and had a problem. The SSH client seemed to lose the connection and the import seemed to freeze. I used another window to login to mysql and the import appeared to be…
Buttle Butkus
  • 1,240
  • 3
  • 11
  • 21
57
votes
4 answers

How do I identify the column(s) responsible for "String or binary data would be truncated."

I am generating some queries automagically with code I wrote to SELECT from a remote Pg database, and insert into a local SQL Server database. However, one of them is generating this error: [Microsoft][ODBC SQL Server Driver][SQL Server]String or…
Evan Carroll
  • 63,051
  • 46
  • 242
  • 479