Most Popular
1500 questions
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
6 answers
How to insert (file) data into a PostgreSQL bytea column?
This question is not about bytea v. oid v. blobs v. large objects, etc.
I have a table containing a primary key integer field and a bytea field. I'd like to enter data into the bytea field. This can, presumably, be done by one of the PL/…
SabreWolfy
- 949
- 1
- 7
- 16
58
votes
7 answers
EXISTS (SELECT 1 ...) vs EXISTS (SELECT * ...) One or the other?
Whenever I need to check for the existence of some row in a table, I tend to write always a condition like:
SELECT a, b, c
FROM a_table
WHERE EXISTS
(SELECT * -- This is what I normally write
FROM another_table
WHERE…
joanolo
- 13,657
- 8
- 39
- 67
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,682
- 3
- 33
- 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,230
- 3
- 11
- 21
57
votes
7 answers
Why should I create an ID column when I can use others as key fields?
Possible Duplicate:
Why use an int as a lookup table's primary key?
So far, I'm accustomed to creating an ID column for every table and it is practical in a way that it makes me not think about decision making about primary key theories.
The…
Uğur Gümüşhan
- 717
- 2
- 6
- 12
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
- 65,432
- 50
- 254
- 507
57
votes
6 answers
How to combine date and time to datetime2 in SQL Server?
Given the following components
DECLARE @D DATE = '2013-10-13'
DECLARE @T TIME(7) = '23:59:59.9999999'
What is the best way of combining them to produce a DATETIME2(7) result with value '2013-10-13 23:59:59.9999999'?
Some things which don't work are…
Martin Smith
- 87,941
- 15
- 255
- 354
57
votes
3 answers
How can I see the current Database Mail configuration?
Our SQL Server (2008) instance is configured to send mail and everything is working correctly, but I can't figure out how to view the existing configuration, in particular the SMTP server.
From SSMS I can only start the configuration wizard, and I…
Alex
- 673
- 1
- 5
- 6
57
votes
4 answers
How to turn off header only in psql (postgresql)
I'm using PostgreSQL 9.1.X
I am trying to build psql script to print results without a header but including a footer.
http://www.postgresql.org/docs/9.1/static/app-psql.html
From the document above
\pset tuples_only
will turn both header and…
skong
- 671
- 1
- 5
- 3
57
votes
2 answers
What is the purpose of the database 'owner'?
Today while troubleshooting a service broker problem, I discovered that the database owner was the Windows login of an employee who had left the company. His login had been removed and thus the query notifications were failing.
Supposedly the best…
8kb
- 2,639
- 2
- 32
- 36
57
votes
3 answers
What is the optimal data type for an MD5 field?
We are designing a system that is known to be read-heavy (on the order of tens of thousands of reads per minute).
There is a table names that serves as a sort of central registry. Each row has a text field representation and a unique key that is…
bobocopy
- 765
- 1
- 6
- 7
56
votes
2 answers
selecting where two columns are in a set
This might be a silly question, and my suspicion is that I can't do this, but is there a construct in SQL that would allow me to do something like the following:
SELECT whatever WHERE col1,col2 IN ((val1, val2), (val1, val2), ...)
I want to select…
James
- 685
- 1
- 5
- 7
56
votes
1 answer
Is there an analog of GETDATE() that returns DATETIME2
According to MSDN, Getdate(), GetUtcDate(), and CURRENT_TIMESTAMP all return DATETIME. I ran a short test, which confirms that:
CREATE TABLE #t(T DATETIME2(7));
GO
DECLARE @i INT ;
SET @i=1;
WHILE @i<10000 BEGIN ;
INSERT #t…
A-K
- 7,444
- 3
- 35
- 52
56
votes
3 answers
The database principal owns a schema in the database, and cannot be dropped message
I am trying to delete a principal from the database but can't because it owns a schema. When I go to edit the user, however, the box to uncheck schema is blue and unremovable.
How can I remove the principal from these schemas?
rsteckly
- 921
- 1
- 7
- 13