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. [mysql], [postgres], [mssql], or [oracle].

An abbreviation of "Structured Query Language," SQL is a database language used to manage data in relational database management systems.

Due to many vendor implementations of SQL (such as T-SQL for SQL Server & Sybase, PL/SQL for Oracle and PostgreSQL and MySQL) it is a fractured language and syntax that works with one vendor may not work with another.

1274 questions
145
votes
9 answers

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 which will recreate all the tables, stored procedures,…
Matt Sheppard
  • 1,559
  • 2
  • 11
  • 10
144
votes
9 answers

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;
Adam Matan
  • 12,504
  • 19
  • 54
  • 73
125
votes
10 answers

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 (over WCF).
vlebar
  • 1,353
  • 2
  • 8
  • 4
106
votes
3 answers

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 running said command successfully (as the…
rz.
  • 1,163
  • 2
  • 8
  • 7
36
votes
2 answers

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 difference between these forms is that a call by command…
Jin Kim
  • 963
  • 2
  • 9
  • 12
31
votes
1 answer

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 all the data can be read out of these files (I…
hellomynameisjoel
  • 2,170
  • 1
  • 18
  • 23
31
votes
9 answers

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 5 and super-duper fast hard disks (which isn't cheap by…
user1034912
  • 1,335
  • 3
  • 14
  • 20
28
votes
5 answers

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 error: The file 'C:\SQL Directory\DATA\A.mdf'…
smwikipedia
  • 626
  • 4
  • 8
  • 15
27
votes
2 answers

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...
Alexander
27
votes
15 answers

HELP! Production DB was SQL INJECTED!

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 inherited the website from a guy that did it on classic ASP,…
empz
  • 247
  • 1
  • 6
  • 15
26
votes
3 answers

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 PostgreSQL database server? Thanks.
Jin Kim
  • 963
  • 2
  • 9
  • 12
26
votes
26 answers

Most popular misconceptions about networking

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 ended up not being correct, or not entirely correct…
l0c0b0x
  • 11,697
  • 6
  • 46
  • 76
25
votes
4 answers

How to dump a part of a table from PostgreSQL?

I have a PostgreSQL database with a multi-Gb table (which contains a log of certain events). I need to pass the latest events to an analyst - let's say he only needs events from the last month. How can I produce a dump of only those rows that have,…
Leonid Shevtsov
  • 481
  • 1
  • 5
  • 8
22
votes
6 answers

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 in any way inside MySQL? I would prefer to avoid…
The Disintegrator
  • 585
  • 2
  • 6
  • 19
20
votes
8 answers

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 computer and just take Xcopy backups of that…
alexn
  • 375
  • 1
  • 4
  • 10
1
2 3
84 85