Table values being truncated

1

I made code in the declaration part of the real number that word balance that it will get a number with 6 digits and 2 two decimal places after the comma, but all the values that I enter are truncated, how to solve? >

create database uri
default character set utf8
default collate utf8_general_ci;

use uri;

create table pessoas(

 id int not null auto_increment,
 nome varchar(30),
 rua varchar(30),
 cidade varchar(30),
 regiao char(3),
 saldo decimal(6,2),
 primary key(id)

) default charset utf8;

insert into pessoas values
('1','Pedro Augusto da Rocha','Rua Pedro Carlos Hoffman','Porto Alegre','RS','700,00'),
('2','Antonio Carlos Mamel','Av. Pinheiros','Belo Horizonte','MG','3500,50'),
('3','Luiza Augusta Mhor','Rua Salto Grande','Niteroi','RJ','4000,00'),
('4','Jane Ester','Av 7 de setembro','Erechim','RS','800,00'),
('5','Marcos Antônio dos Santos','Av Farrapos','Porto Alegre','RS','4250,25');
SELECT nome FROM pessoas WHERE regiao = 'RS';
    
asked by anonymous 27.04.2018 / 20:49

2 answers

1

You must use period (.) and non-comma (,) to separate the decimal, mysql does not use the Brazilian standard. link

    
27.04.2018 / 20:58
1

Change "," to "." because the field is of the decimal type (only accepts number and the separator for decimal places is the point)

Example:

insert into pessoas values
('1','Pedro Augusto da Rocha','Rua Pedro Carlos Hoffman','Porto Alegre','RS','700.00')
    
27.04.2018 / 20:59