Questions tagged as 'sql'

1
answer

SQL Server "TRIM" Command

I'm working with Sql Server , and I need to trim in a result of a query. I did as follows: select TRIM(NUMERO) from ENDERECO In% w / w the command is "recognized", it is in the coloration of a valid command, but returned the...
asked by 03.01.2019 / 13:53
1
answer

Should I limit the size of VARCHAR columns for performance?

Normally the maximum size for VARCHAR is 255. If I create the column with a smaller size, say VARCHAR (50), will I gain performance or save disk space?     
asked by 11.06.2015 / 14:30
1
answer

Model "Product" table for multiple types of different products

How to model the Product table of a database? This table should store the following information: id, product name, quantity, price, status (if it is in stock, if it will be returned) and information pertinent to each type of product: food (nat...
asked by 14.07.2015 / 14:11
1
answer

What is the difference between REPLACE INTO or ON DUPLICATE KEY UPDATE

I'm wondering what's the difference between using REPLACE INTO or ON DUPLICATE KEY UPDATE in mysql, are not both for the same purpose making a change to a field or more in the database? If the goal is someone else who enlightens me...
asked by 04.10.2017 / 14:07
2
answers

What is a lock and what are its causes?

I often come across the term: Table x is with lock . What does it mean and what are its causes?     
asked by 19.04.2017 / 21:38
2
answers

How do I return the words that appear the most in a column?

I have this table below which has two columns, being id and description : CREATE TABLE myBigTable ( id INT(11) AUTO_INCREMENT PRIMARY KEY, description TEXT NOT NULL ) After inserting some records, I made a simple selec...
asked by 07.03.2017 / 23:00
2
answers

Delete record with duplicate (Id) leaving only one occurrence

This is an old bank, dbase that has been transferred to MSSQL . Home How to leave only one occurrence in the case of id duplicated in a table? | Id| Nome | |-----------| | 1 | JOSE | | 1 | JOSE | | 2 | MARIA | | 2 | MARI...
asked by 03.12.2015 / 15:36
1
answer

Rounding as a result of multiplication

I have this scenario:  - do a multiplication of 2 values that will be rounded to 2 boxes for the table that will be inserted its result. Follow the example: CREATE TABLE #TMP ( A DECIMAL(23,6), B DECIMAL(28,2) ) INSERT INTO #TMP VAL...
asked by 05.01.2016 / 20:58
2
answers

Change boolean column to integer

I'm using a database that has a field called: status: boolean , however I want to store the values of the Radio Button (0,1,2) so I need to change to integer . I'vetried:ALTERTABLEOSALTERCOLUMNSTATUSTYPEBOOLEANUSING(trim(STATUS):...
asked by 24.10.2017 / 17:46
1
answer

What is a database procedure?

At times I have been following questions that involve the term procedure in database, then doubts: What is procedure ? Where to use it, what is it for? If possible use examples clear the mind of the layman (mine).     
asked by 29.09.2017 / 02:02