Cara menggunakan decimal phpmyadmin

To those still experiencing this, and don't want to wait for it to randomly work again:

I just encountered this, and cannot find any explanation other than some bug.

I tried:

CREATE TABLE `database`.`measurement_types` ( 
    `TypeID` INT(2) NOT NULL AUTO_INCREMENT , 
    `Name` VARCHAR(32) NOT NULL , 
    `Description` VARCHAR(256) NOT NULL , 
    PRIMARY KEY (`TypeID`)) ENGINE = InnoDB;

Which produced the same "Please enter valid length" error

Tried a few times with different length values, but kept getting the same error.

--SOLUTION--

So I just created the table with a single column first, then altered it with the two other columns like so:

CREATE TABLE `database`.`measurement_types` ( 
    `TypeID` INT(2) NOT NULL AUTO_INCREMENT , 
    PRIMARY KEY (`TypeID`)) ENGINE = InnoDB;

And then:

ALTER TABLE `measurement_types` 
    ADD `Name` VARCHAR(32) NOT NULL AFTER `TypeID`, 
    ADD `Description` VARCHAR(256) NOT NULL AFTER `Name`;

And that worked.

I also tried to delete the table and create it with the first SQL again, and this time it worked. Seems pretty random


You need to select a database when you are creating a table. Right now, I have a sample database. The snapshot is as follows:

Cara menggunakan decimal phpmyadmin

Now you need to give the table name as well as the number of columns you want:

Cara menggunakan decimal phpmyadmin

After that you need to press Go button. Now, the following section would be visible:

Cara menggunakan decimal phpmyadmin

The DECIMAL requires two parameter i.e. Total Number of Digit and second one is DigitAfterDecimalPoint.

The structure of DECIMAL is as follows:

DECIMAL(X,Y)

Here, X is TotalNumberOfDigit and Y is DigitAfterDecimalPoint.

Let us see an example:

DECIMAL(6,4)

Above, we will be having 6 digit sand 2 digit safter decimal point. For example, the valid range can be 24.5678 or 560.23 etc.

Here is the setup in phpmyAdmin. The snapshot is as follows:

Cara menggunakan decimal phpmyadmin

After giving column name for a table, you need to use “Save” button. Here is the structure of table:

Cara menggunakan decimal phpmyadmin

There are two columns in the table DecimalPrecisionDemo. One is Id which is of type int and second one is Amount of type DECIMAL(6,4).

Cara menggunakan decimal phpmyadmin

Updated on 30-Jul-2019 22:30:24

  • Related Questions & Answers
  • How to add auto-increment to column in MySQL database using PhpMyAdmin?
  • How to insert DECIMAL into MySQL database?
  • How to store the PayPal decimal amount in the MySQL database?
  • Connect to external server by using phpMyAdmin
  • How to format number to 2 decimal places in MySQL?
  • How to increase precision with division in MySQL?
  • Creating and Using a MySQL Database
  • How to convert a decimal number to roman using JavaScript?
  • How to take MySQL database backup using MySQL Workbench?
  • How to use MySQL decimal?
  • How to store decimal in MySQL?
  • How to deal with floating point number precision in JavaScript?
  • PHP – How to raise an arbitrary precision number to another using bcpow() function?
  • How to know the exact number of table and columns in a MySQL database?
  • How to specify options for MySQL programs?

Tipe data decimal biasa digunakan untuk pencatatan transaksi keuangan. Dalam mengembangkan aplikasi yang mengandung transaksi keuangan kita perlu memahami tipe data ini dengan baik.

Tipe data decimal dikenal dengan DECIMAL(M,D).
M merupakan banyaknya angka yang akan ditunjukkan secara akurat.
D merupakan jumlah digit di belakang koma.

Sebagai contoh:
a. decimal(5,2) mempunyai nilai maksimum 999,99 atau dari -999,99 sampai dengan 999,99
b. decimal(8,2) mempunyai nilai maksimum 999.999,99 atau 999 ribu
c. decimal(11,2) mempunyai nilai maksimum 999.999.999,99 atau 999 juta
d. decimal(14,2) mempunyai nilai maksimum 999.999.999.999,99 atau 999 milyar
e. decimal(15,2) mempunyai nilai maksimum 9.999.999.999.999,99 atau 9 triliun

Jika tipe data untuk transaksi keuangan kita kita set ke decimal(15,2) berarti setiap data yang bisa masuk ke tabel tersebut maksimum 9 triliun.

Kadang kuantitas ada yang menggunakan koma misal 2,125 liter.
Kita dapat menggunakan decimal(12,3) yang nilai maksimumnya 999.999.999,9 atau 999 juta atau hampir 1 miliar.

Informasi lebih lanjut silahkan mengunjungi http://dev.mysql.com/doc/refman/5.6/en/precision-math-decimal-characteristics.html .

Artikel terkait:
1. http://www.proweb.co.id/articles/web_application/instal_xampp_centos_6.html
2. http://www.proweb.co.id/articles/web_application/standarisasi_amp.html
3. http://www.proweb.co.id/articles/web_application/standar_field_table.html
4. http://www.proweb.co.id/articles/support/decimal_mysql.html
5. http://www.proweb.co.id/articles/support/strict_mode_mysql.html

Kunjungi www.proweb.co.id untuk menambah wawasan anda.

Tipe data decimal untuk apa?

Tipe data decimal biasa digunakan untuk pencatatan transaksi keuangan. Dalam mengembangkan aplikasi yang mengandung transaksi keuangan kita perlu memahami tipe data ini dengan baik. Tipe data decimal dikenal dengan DECIMAL(M,D). M merupakan banyaknya angka yang akan ditunjukkan secara akurat.

Berapakah jumlah ukuran memori pada tipe data Tinyint?

TINYINT memiliki jangkauan angka dari -128 sampai 127, dengan maksimal penyimpanan jumlah angka dari 0 sampai 255.

Apa itu int dalam basis data?

Integer (int.) merupakan data type berbentuk bilangan bulat atau numerik yang umumnya digunakan untuk menyimpan angka tanpa komponen pecahan dengan rentang angka -707, 0, hingga 707. Menurut BBC, data type ini mencakup semua bilangan bulat atau bilangan yang tidak memiliki komponen pecahan.

Tipe tipe data apa saja yang disediakan oleh MySQL?

Secara umum tipe data pada MySQL dibagi menjadi 4 yaitu: Numeric Values yaitu angka atau bilangan seperti 10; 123; 100.50; -10; 1.2E+17; 2.7e-11; dan sebagainya..
DATETIME. Kombinasi tanggal dan waktu. ... .
DATE. Kombinasi tanggal dan waktu. ... .
TIMESTAMP. TIMESTAMP [(M)] ... .