Most Popular

1500 questions
51
votes
4 answers

What is the difference between sys and system accounts in Oracle databases?

There are two ways to connect to Oracle as an administrator using SQL Plus: sqlplus sys as sysdba sqlplus system/manager These accounts should be used for different purposes, I suppose. Which tasks are these two schemas meant for? When should I…
Lazer
  • 3,361
  • 15
  • 43
  • 53
51
votes
5 answers

How export a sql server 2008 diagram to PDF filetype?

I want to have an export from my database diagram to PDF or image types. How can I do this? I worked with SQL Server 2008 R2.
Hamid Talebi
  • 615
  • 1
  • 6
  • 8
51
votes
8 answers

Writing select result to a csv file

We need to write the SELECT query results to a csv file. How can it be done using T-SQL in SQL Server 2008 r2? I know that it can be done in SSIS, but for some reasons, we don't have this option. I tried to use the suggested proc in the article…
Sky
  • 3,744
  • 18
  • 53
  • 68
51
votes
5 answers

Aggressive Autovacuum on PostgreSQL

I'm trying to get PostgreSQL to aggressively auto vacuum my database. I've currently configured auto vacuum as follows: autovacuum_vacuum_cost_delay = 0 #Turn off cost based vacuum autovacuum_vacuum_cost_limit = 10000 #Max…
CadentOrange
  • 783
  • 1
  • 8
  • 10
51
votes
2 answers

postgresql: how to define a JSONB column with default value

I am unable to find in the documentation how to create a JSONB column in PostgreSQL that has a DEFAULT value of an empty json document. How the above can be stated in the CREATE TABLE definition ?
nskalis
  • 1,721
  • 4
  • 15
  • 12
51
votes
6 answers

In MySQL, does the order of the columns in a WHERE clause affect query performance?

I am having performance issues on certain database queries that have large possible result sets. The query in question, I have three ANDs in the WHERE clause Does the order of the clauses matter? As in, if I put the ASI_EVENT_TIME clause first…
Patrick
  • 4,329
  • 7
  • 29
  • 28
51
votes
4 answers

What are Objective Business Reasons to Prefer SQL Server 2012 over 2008 R2?

My company is facing the decision whether to purchase SQL Server 2012 Denali or SQL Server 2008 R2 for a new database server. I am looking for objective reasons to choose one over the other. Our requirements: Standard edition (for financial reasons…
usr
  • 7,390
  • 5
  • 33
  • 58
51
votes
4 answers

How can I move a MySQL database to another drive?

I'm using MySQL 5.5 on a local machine to analyze a large amount of government data. I've created a local database that resides on my default drive (Win7 C: drive). I'd like to store the data on my E: drive, a large eSATA external drive. What steps…
user1243473
51
votes
1 answer

Is there a maximum length constraint for a postgres query?

The app we are building might execute quite a big insert queries. Is there limit that my postgres query can have only a certain number of characters?
Kannan Ramamoorthy
  • 657
  • 2
  • 7
  • 8
51
votes
2 answers

SQL Server - granting permissions to an entire schema vs. object?

I'm very green when it comes to the world of database permissions management in SQL Sever. Let's keep an example simple. Say account 'admin' is the owner of schemas A, B, and C. There another account 'minion' that you want to have full rights…
user45867
  • 1,739
  • 5
  • 24
  • 41
51
votes
2 answers

Best way to get last identity inserted in a table

Which one is the best option to get the identity value I just generated via an insert? What is the impact of these statements in terms of performance? SCOPE_IDENTITY() Aggregate function MAX() SELECT TOP 1 IdentityColumn FROM TableName ORDER BY…
AA.SC
  • 4,073
  • 4
  • 28
  • 45
51
votes
4 answers

SQL Server commands to clear caches before running a performance comparison

When comparing the execution time of two different queries, it's important to clear the cache to make sure that the execution of the first query does not alter the performance of the second. In a Google Search, I could find these commands: DBCC…
andrerpena
  • 981
  • 3
  • 11
  • 13
50
votes
6 answers

Why do we use Group by 1 and Group by 1,2,3 in SQL query?

In SQL queries, we do use Group by clause to apply aggregate functions. But what is the purpose behind using numeric value instead of column name with Group by clause? For example: Group by 1.
ursitesion
  • 2,061
  • 8
  • 32
  • 45
50
votes
1 answer

SQL injection in Postgres functions vs prepared queries

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?
user4930
50
votes
8 answers

Is it possible to mysqldump a subset of a database required to reproduce a query?

Background I would like to provide the subset of my database required to reproduce a select query. My goal is to make my computational workflow reproducible (as in reproducible research). Question Is there a way that I can incorporate this select…
David LeBauer
  • 3,162
  • 8
  • 32
  • 34