We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [sql]

Database language for managing data in relational database management systems (RDBMS). Note that each database implements SQL with slight variations. Please remember to tag with your specific database as well, e.g. [tag:mysql], [tag:postgres], [tag:mssql], [tag:oracle]

Filter by
Sorted by
Tagged with
126
votes
9answers
174k views

How to dump a Microsoft SQL Server database to a SQL script?

Is there any way to export a Microsoft SQL Server database to an sql script? I'm looking for something which behaves similarly to mysqldump, taking a database name, and producing a single script ...
87
votes
8answers
184k views

GRANT SELECT to all tables in postgresql

Is there a one-liner that grants the SELECT permissions to a new user postgresql? Something that would implement the following pseudo-code: GRANT SELECT ON TABLE * TO my_new_user;
66
votes
8answers
60k views

Is there an equivalent of MySQL's SHOW CREATE TABLE in Postgres?

Is there an equivalent of MySQL's SHOW CREATE TABLE in Postgres? Is this possible? If not what is the next best solution? I need the statement because I use it to create the table on an remote server ...
60
votes
2answers
137k views

Postgresql: what does GRANT ALL PRIVILEGES ON DATABASE do?

I'm trying to grant all privileges on all tables of a given database to a new postgres user (not the owner). It seems that GRANT ALL PRIVILEGES ON DATABASE my_db TO new_user; does not do that. After ...
34
votes
2answers
10k views

Postgres: Non zero exit code when executing a sql file?

I am writing a shell script which makes calls to psql using 2 forms... one is by command (-c), the other is by file (-f). e.g. psql -c "create table foo (bar integer)" psql -f foobar.sql One ...
31
votes
9answers
15k views

To improve SQL performance, why not just put lots of RAM rather than having faster hard disks?

People keep telling me that in order to improve an SQL server's performance, buy the fastest hard disks possible with RAID 5, etc. So I was thinking, instead of spending all the money for RAID&...
27
votes
2answers
30k views

How to change in postgresql password of the user using SQL

How to change in postgresql password of the user using SQL. I have user (alex) and his password (e.g. pass) i need to change using sql statement his password to NULL...
26
votes
26answers
2k views

Most popular misconceptions about networking [closed]

00000001 + 00000001 = 00000011 alt text http://locobox.googlepages.com/red_x_round.png Misconceptions about Networking* Time to fess-up!... 'at some point' you thought you knew something, and it ...
26
votes
15answers
4k views

HELP! Production DB was SQL INJECTED! [duplicate]

Possible Duplicate: My server's been hacked EMERGENCY Geeze, I'm desperate! A few hours ago our production DB was sql-injected. I know we have some big holes in the system... because we ...
23
votes
3answers
57k views

Postgres: How can I see all SQL statements being executed by the database server?

I'm in the process of reviewing every SQL statement that an application makes against the database, for performance reasons. Is there an easy way to log all statements that are executed by the ...
23
votes
1answer
28k views

How can I verify that a SQLite db3 file is valid/consistent

I have some sqlite version3 db3 files I copied off a live running production system (I know bad sysadmin bad sysadmin) for various reasons. Is there some sqlite command I can run that will verify that ...
21
votes
5answers
53k views

mdf file cannot be overwritten when restoring a database in SQL Server

I got a databse A. It has some data in it. I created a backup for A as A.bak file. Then I create a new empty database B. And then I try to restore B from A.bak. But the SQL Serve tell me the following ...
20
votes
8answers
68k views

SQL Server 2008 Express - “Best” backup solution?

What backup solutions would you recommend when using SQL Server 2008 Express? I'm pretty new to SQL Server, but as I'm coming from an MySQL background I thought of setting up replication on another ...
18
votes
4answers
25k views

Alter charset and collation in all columns in all tables in MySQL

I need to execute these statements in all tables for all columns. alter table table_name charset=utf8; alter table table_name alter column column_name charset=utf8; Is it possible to automate this ...
16
votes
6answers
42k views

How do I change the collation of a SQL Server Database?

I'm trying to standardise all databases on a single collation - Latin1_General_CI_AS (the standard collation). I have some databases that are in SQL_Latin1_General_CP1_CI_AS. I know I can use ALTER ...
15
votes
1answer
42k views

How do you get the minimum and maximum memory allocation of a SQL instance using T-SQL?

I'm managing about 90 SQL Server instances and need a query to determine how much memory has been allocated to each instance. Please note, I'm not asking how to set it, just to see what it's currently ...
14
votes
6answers
25k views

How can I diff two Oracle 10g Schemas?

I have the feeling that there are some difference between two large complicated Oracle schemas which should be identical, so decided to dump and diff them to investigate. I found an article (http://...
13
votes
2answers
2k views

Is there a MySQL performance benchmark to measure the impact of utf8_unicode_ci versus utf8_general_ci?

I read here and there that using the utf8_unicode_ci collation ensures a better treatment of unicode text (for example, it knowns how to expand characters such as 'œ' into 'oe' for searching and ...
12
votes
2answers
50k views

Difference between “NT AUTHORITY\NETWORK SERVICE” and “NT AUTHORITY\SYSTEM”

I am installing MS SQL Server 2008 R2 and I got to the window where I have to set the service accounts. I want to know the difference between NT AUTHORITY\SYSTEM" and "NT AUTHORITY\NETWORK SERVICE". I ...
12
votes
5answers
17k views

How to load-balance SQL Server 2008 for high-usage ASP.NET applications?

Imagine that you have a successful web application that uses ASP.NET and IIS 7. It generates many calls to a SQL Server 2008 database, and is expected to be available to the public with 99.9% uptime (...
10
votes
2answers
4k views

disable maximum password length on Windows Server [closed]

When trying to create a password longer than 16 chars on my Windows 2012 server, it is refused due to the password being to long. I have tried looking for a GPO called "Maximum Password Length" - ...
10
votes
3answers
9k views

SQL Server: Statements vs. Batches vs. Transactions vs. Connections

My question is simple: What are the differences / similarities / cardinalities between Transactions Batches Connections and Statements in SQL Server? As far as I understand a connection is a ...
9
votes
2answers
15k views

How to count unique values?

I am trying get the number of unique ip_addresses (in this case '3'). The table looks like this: Structure: CREATE TABLE bandits ( key text NOT NULL, ip_address inet, offence text, count ...
9
votes
2answers
6k views

DB auto failover in c# does not work when the principal server physically goes offline

I'm setting up DB auto failover in C# with SQL Server 2008 and I have a 'high safety with automatic failover mirror' using a witness setup and my connection string looks like "Server=tcp:DC01; ...
8
votes
4answers
21k views

What do I do when pg_cancel_backend doesn't work?

If I have a long-running Postgres query, and regular "kill [pid]" doesn't work, and pg_cancel_backend doesn't work, what should I do?
8
votes
2answers
21k views

Alias a linked Server in SQL server management studio?

Hoping someone can help - is there a way in SQL server management studio 2008 R2 that I can alias a linked SQL server? I have a server, added by IP address, to which I do not have the login ...
8
votes
7answers
16k views

DHCP server with database backend [closed]

I have been looking around for something to replace my (ancient) ISC-DHCPd server. A DHCP server with a database backend sounds like a great idea to me, as I could then have a nice, friendly web ...
8
votes
2answers
2k views

Is it a good idea to back up SQL database to an External USB Hard Drive?

I will be installing a Database System on an Offshore Oil Platform (rack Servers). They have very limited hardware and space therefore sending up a backup infrastructure is not possible. Sending ...
8
votes
3answers
19k views

mysqldump ignore table with wildcard

I need to take a dump of a database containing 50 odd tables of which I want to exclude about 15 odd that have prefix exam_ I tried mysqldump --ignore-table=dbname.exam_* and even tried --ignore-...
8
votes
1answer
20k views

Change collation of a MySQL table to utf8_general_cs

I tried to change collation MySQL table to utf8_general_cs but got following error: mysql> ALTER TABLE table_name CONVERT TO CHARACTER SET utf8 COLLATE 'utf8_general_cs'; ERROR 1273 (HY000): ...
8
votes
5answers
20k views

Calling sp_start_job from a stored procedure

Our developers need to be able to start a SQL Server Agent job from their .Net code. I know I can call msdb..sp_start_job to do just that, but I don't want to give general user accounts direct access ...
8
votes
7answers
4k views

Is MySQL better than PostgreSQL in something?

I know the question sounds provocative, but it really isn't. I'm lately finding MySQL limiting in a lot of areas and liking PostgreSQL more and more. It scales a lot better and it respects the SQL ...
8
votes
3answers
3k views

Is there an easier way of resolving SQL Server/database collation mismatches than changing every column?

DISCLAIMER: I know that this question has been asked a hundred times before, but I just wanted to check that there wasn't an easier solution I might have missed before I went ahead and wrote/sourced ...
8
votes
1answer
2k views

Are vCPU the same as 1 Socket, or a single Core?

Currently I have a Hyper-v VPS with 2 (vCPU) processor. I would like to install SQL Server Express 2012 that has a limitation of 1 Socket or 4 Cores, whichever the lesser. My Question: Are vCPU's ...
8
votes
3answers
18k views

Creating a sql dump of Microsoft Access tables

Is it possible to generate a sql script that contains CREATE and INSERT statements for some tables within an Access database?
7
votes
8answers
4k views

Should I ever DELETE (SQL and DB) anything?

I am curious, should I ever delete anything? Right now I am building a site (for myself) which allows you to subscribe to users which you then receive a message every time the user has upload content. ...
7
votes
3answers
1k views

Is a MySQL database a viable alternative to LDAP?

(Apologies if I'm asking the wrong kind of question or in the wrong place.) We run IT for our association (all volunteers). We have got a server with member database in OpenLDAP, mail server, ftp and ...
7
votes
3answers
22k views

Postgres INSERT ERROR: permission denied for schema public

In Postgres I created the following table inside a db called testing: CREATE TABLE category_google_taxonomy ( category_id integer references category ON UPDATE CASCADE ON DELETE CASCADE, ...
7
votes
2answers
15k views

How to attach mdf files from a different SQL Server Install?

Hi I have mdf and ldf files from a different SQL Server install from a machine i dont have access to now, and would like attach them to my current install to get at the data. When I try this, I get an ...
7
votes
3answers
17k views

How to monitor activity on a single table using SQL Server profiler

I have a table which uses and identity seed for its unique identity column. We have noticed some massive jumps in the identity value which we are not able to explain. The table has 20,000 odd rows, ...
6
votes
7answers
30k views

How to rollback a deleted table data?

I have deleted one table accidentally how can I rollback that. Please suggest that.
6
votes
6answers
1k views

How should I set up protection for the database against sql injection when all the php scripts are flawed?

I've inherited a php web app that is very insecure, with a history of sql injection. I can't fix the scripts immediately, I rather need them to be running to have the website running, and there are ...
6
votes
5answers
83k views

How can I tell if an Oracle database is mounted and activated?

IANADBA, but I'm writing a script that will take action as long as the oracle standby database hasn't been activated. What I'm looking for is two queries (or sets of queries, if necessary). 1 - Is ...
6
votes
2answers
2k views

My table half-exists. Can't drop it

I have a table that is taking up quite a bit of space even though it has no rows. I also dropped it a while ago. When I try to drop it now, it says the table doesn't exist. It shows up in user_tables....
6
votes
3answers
6k views

Renamed a SQL Server, however maintenance plans still have old name

A colleague has renamed a SQL server, however all of the maintenance plans still have references to 'OLD_NAME' as 'Local Server Connection'. The text boxes containing the server names for Local ...
6
votes
1answer
29k views

dbcc checkdb('XYZ', REPAIR_ALLOW_DATA_LOSS) indicating that XYZ is already open and can only have one user at a time

I have a DB, XYZ, that had a corrupt log file and now since the log file is totally unusable this is rendering this specific DB unusable and I need to be able to rebuild it. I've already done a lot ...
6
votes
1answer
18k views

Send sql server job alert only when a query has rows to return

I have a query that checks if we've made sales of a particular stock item select * from merchand_history where stock_code = 'zzz007' and create_timestamp >= getdate() order by create_timestamp ...
6
votes
4answers
28k views

How to find the next generated value for a auto-increment column?

I face some trouble with IBM DB2's auto-increment columns. At first, all my columns were defined as GENERATED ALWAYS, but since I had trouble with this when using the "db2 import ..." command, I ...
6
votes
1answer
3k views

On Amazon Web Services what is the difference between SQL Server Standard and SQL Server Web?

I noticed that SQL Server Web is vastly cheaper than SQL Server Standard on Amazon Web Services. Why is that? What am I missing if I use SQL Server Web instead of Standard?
6
votes
4answers
8k views

SQL Server 2008 R2 Error 15401 when trying to add a domain user

I am trying to add a domain user. I am doing the following. Expand Security Right click on Logins Select New Login... Login name select search Click on location and select entire directory Type ...