Questions tagged as 'sql'

5
answers

Difference between two dates in days, hours, minutes and seconds

Problem: How to perform the subtraction between two dates and return the value in Days, Hours, Minutes and Seconds in a SQL query with SQL Server 2014? Example: Dados: DataRecebimento DataEnvio 2013-11-29 11:30:40.157 2014-05-2...
asked by 11.07.2014 / 17:43
2
answers

What is the difference between where and having?

Doing some testing on a database in MySQL, I realized that: SELECT * From client WHERE uuid = '1kvsg4oracxq' returns the same result as: SELECT * From client HAVING uuid = '1kvsg4oracxq' What exactly is the difference between where...
asked by 09.06.2017 / 21:06
2
answers

What are schemas? What are the advantages of using it?

In which situations is its use recommended?     
asked by 11.06.2014 / 22:09
3
answers

When is the recommended use of composite primary key?

   A simple key is associated with a single value, or field, of the record. A compound key corresponds to the combination of two or more keys, and may be necessary to eliminate ambiguity, forming a unique identifier. ( Wikipedia ) Let's...
asked by 15.05.2014 / 14:21
3
answers

How to select all but one specific column?

You can select all columns in a table: SELECT * FROM wp_rw_programacao WHERE id = $id But I need to eliminate the id column from the result. Is it possible?     
asked by 19.10.2017 / 17:09
4
answers

Regarding object orientation, should queries have a class of their own or can they be in a specific class?

What I have is the following: a user class and a connection class with the bank. I need to insert a user into a database, the query " insert into usuarios values (..) " should be in my user class or in the database class? I think o...
asked by 11.12.2015 / 15:02
4
answers

Is it recommended to use a natural primary key?

Natural primary key is one that contains a real data, not just a random value, as an integer. Example: // comum CREATE TABLE pessoas ( id INTEGER PRIMARY KEY, cpf INTEGER NOT NULL, // outros campos ); // chave natural CREATE TABLE pe...
asked by 11.08.2014 / 15:26
2
answers

What is an upsert?

I saw the term UPSERT in a blog and would like to better understand how it works. Does it designate what kind of operation? In what situations can it be used? Does it have idempotency ?
asked by 22.08.2018 / 20:30
2
answers

Is it better to parameterize your PreparedStatement even if the value is fixed?

I always read the blog Java Revisited and I was reading the article today Why use PreparedStatement in Java JDBC - Example Tutorial . At one point the author talks about parameterization of queries, it is better, safer and more performative to...
asked by 14.02.2014 / 19:25
3
answers

What is the index for SQL Server?

For what the index serves, I know it improves performance, but what the database does behind it improves this performance. When is it recommended to use? And where should I use an index?     
asked by 05.08.2014 / 17:51