Most Popular

1500 questions
39
votes
5 answers

Logical operators OR AND in condition and order of conditions in WHERE

Let's examine these two statements: IF (CONDITION 1) OR (CONDITION 2) ... IF (CONDITION 3) AND (CONDITION 4) ... If CONDITION 1 is TRUE, will CONDITION 2 be checked? If CONDITION 3 is FALSE, will CONDITION 4 be checked? What about conditions on…
garik
  • 6,722
  • 10
  • 43
  • 56
39
votes
6 answers

Why don't databases create their own indexes automatically?

I would have thought that databases would know enough about what they encounter often and be able to respond to the demands they're placed under that they could decide to add indexes to highly requested data.
Jharwood
  • 805
  • 2
  • 11
  • 19
39
votes
3 answers

The login already has an account under a different user name

When I execute this SQL: USE ASPState GO IF NOT EXISTS(SELECT * FROM sys.sysusers WHERE NAME = 'R2Server\AAOUser') CREATE USER [R2Server\AAOUser] FOR LOGIN [R2Server\AAOUser]; GO I get the following error: The login already has an account under a…
Jack
  • 2,509
  • 14
  • 36
  • 42
39
votes
3 answers

MySQL 5.1.66 SSL connection error ERROR 2026 (HY000)

UPDATE2 Using WireShark I found out the problem string (I hope I did): 28 | 9.582638 | 192.168.18.128 | 192.168.18.129 | MySQL Response Error 1043 And the error is (according to docs): Error: 1043 SQLSTATE: 08S01 (ER_HANDSHAKE_ERROR) Message: Bad…
Sergei Danielian
  • 440
  • 1
  • 4
  • 9
39
votes
5 answers

In SQL, is it composite or compound keys?

About SQL (Computing/Databases): When we have two or more fields in a table that, together, identify its records uniquely, what's the proper way of calling them? Composite or compound keys? I've seen on the web both uses so I'm not really sure.
igordcard
  • 493
  • 1
  • 4
  • 6
39
votes
5 answers

Set names to attributes when creating JSON with row_to_json

Is it possible to rename default f1, f2, f3... names when using row_to_json function for only some columns? I can do row_to_json(customers) returning {"id_customer":2,"first_name":"bla","last_name":"second_bla"} But if I want only names without…
boobiq
  • 807
  • 3
  • 9
  • 13
39
votes
5 answers

Can I write portable SQL statements?

I am wondering if it is possible to write SQL statements that are 100% interoperable with most or all databases including: MariaDB/MySQL/Percona Postgres Microsoft SQL Oracle SQLite (Eg, can I just follow a specific SQL standard? Eg, is there…
James Shewey
  • 505
  • 5
  • 8
39
votes
2 answers

ALTER TABLE CHECK CONSTRAINT

From the Object Explorer in SQL Server, when selecting and scripting a foreign-key constraint, the following code is generated. USE [MyTestDatabase] GO ALTER TABLE [dbo].[T2] WITH NOCHECK ADD CONSTRAINT [FK_T2_T1] FOREIGN…
Delux
  • 774
  • 1
  • 7
  • 14
39
votes
1 answer

How do you create a view with SNAPSHOT_MATERIALIZATION in SQL Server 2017?

SQL Server 2017 has a couple new stored procedures: sp_refresh_single_snapshot_view – input param for @view_name nvarchar(261), @rgCode int sp_refresh_snapshot_views – input param for @rgCode int And new entries in sys.messages: 10149 – Index…
Brent Ozar
  • 42,952
  • 47
  • 220
  • 375
39
votes
8 answers

Does SQL Server support GREATEST and LEAST, if not what is the common workaround?

Reviewing this question it seems like that's a lot of work that shouldn't be needed. They're trying to extend a range with a date. In other databases, you would just use greatest and least.. least(extendDate,min), greatest(extendDate,max) When I…
Evan Carroll
  • 63,051
  • 46
  • 242
  • 479
39
votes
3 answers

Are regular VACUUM ANALYZE still recommended under 9.1?

I'm using PostgreSQL 9.1 on Ubuntu. Are scheduled VACUUM ANALYZE still recommended, or is autovacuum enough to take care of all needs? If the answer is "it depends", then: I have a largish database (30 GiB compressed dump size, 200 GiB data…
François Beausoleil
  • 1,433
  • 3
  • 15
  • 24
39
votes
4 answers

Blue icon with question mark - what does it mean?

The SQL Server instance is accessible and seems to be fine. Microsoft SQL Server 2016 (SP1-CU2) (KB4013106) - 13.0.4422.0 (X64) Mar 6 2017 14:18:16 Copyright (c) Microsoft Corporation Enterprise Edition (64-bit) on Windows Server 2012 R2…
Marcello Miorelli
  • 16,170
  • 52
  • 163
  • 300