Cara menggunakan increase table size mysql

Use highlight tables to compare categorical data using color.

In Tableau, you create a highlight table by placing one or more dimensions on the Columns shelf and one or more dimensions on the Rows shelf. You then select Square as the mark type and place a measure of interest on the Color shelf.

You can enhance this basic highlight table by setting the size and shape of the table cells to create a heat map.

To create a highlight table to explore how profit varies across regions, product sub-categories, and customer segments, follow these steps:

  1. Connect to the Sample - Superstore data source.

  2. Drag the Segment dimension to Columns.

    Tableau creates headers with labels derived from the dimension member names.

  3. Drag the Region and Sub-Category dimensions to Rows, dropping Sub-Category to the right of Region.

    Now you have a nested table of categorical data (that is, the Sub-Category dimension is nested within the Region dimension).

  4. Drag the Profit measure to Color on the Marks card.

    Tableau aggregates the measure as a sum. The color legend reflects the continuous data range.

    Cara menggunakan increase table size mysql

    In this view, you can see data for only the Central region. Scroll down to see data for other regions.

    In the Central region, copiers are shown to be the most profitable sub-category, and binders and appliances the least profitable.

  5. Click Color on the Marks card to display configuration options. In the Border drop-down list, select a medium gray color for cell borders, as in the following image:

    Cara menggunakan increase table size mysql

    Now it's easier to see the individual cells in the view:

    Cara menggunakan increase table size mysql

  6. The default color palette is Orange-Blue Diverging. A Red-Green Diverging palette might be more appropriate for profit. To change the color palette and to make the colors more distinct, do the following:

    • Hover over the SUM(Profit) color legend, then click the drop-down arrow that appears and select Edit Colors.

    • In the Edit Colors dialog box, in the Palette field, select Red-Green Diverging from the drop-down list.

    • Select the Use Full Color Range check box and click Apply and then click OK.

      Cara menggunakan increase table size mysql

      When you select this option, Tableau assigns the starting number a full intensity and the ending number a full intensity. If the range is from -10 to 100, the color representing negative numbers changes in shade much more quickly than the color representing positive numbers.

      When you do not select Use Full Color Range, Tableau assigns the color intensity as if the range was from -100 to 100, so that the change in shade is the same on both sides of zero. The effect is to make the color contrasts in your view much more distinct.

      For more information about color options, see Color Palettes and Effects.

      Cara menggunakan increase table size mysql

Modify the size to create a heat map

  1. Drag the Sales measure to Size on the Marks card to control the size of the boxes by the Sales measure. You can compare absolute sales numbers (by size of the boxes) and profit (by color).

    Initially, the marks look like this:

    Cara menggunakan increase table size mysql

  2. To enlarge the marks, click Size on the Marks card to display a size slider:

    Cara menggunakan increase table size mysql

  3. Drag the slider to the right until the boxes in the view are the optimal size. Now your view is complete:

    Cara menggunakan increase table size mysql

Check your work! Watch steps 1-9 below:

Cara menggunakan increase table size mysql

Note: In Tableau 2020.2 and later, the Data pane no longer shows Dimensions and Measures as labels. Fields are listed by table or folder.

Jika pada 5 tutorial MySQL sebelum ini kita telah mempelajari tentang tipe data tabel MySQL dan atribut tipe data tabel MySQL, pada tutorial kali ini akan dibahas tentang bagaimana merubah atau mengubah serta modifikasi tabel MySQL setelah tabel itu dibuat. Query yang akan kita pelajari adalah ALTER TABLE.


Ada kalanya setelah sebuah tabel MySQL dibuat, kita ingin mengubah struktur tabel tersebut. Entah itu berupa penambahan kolom baru, atau penghapusan sebuah kolom untuk digantikan dengan kolom lain.

Query untuk membuat tabel (CREATE TABLE) dan menghapus tabel (DROP TABLE) sudah kita bahas pada Tutorial MySQL: Cara Membuat dan Menghapus Tabel MySQL. Kali ini kita akan menggunakan perintah ALTER TABLE untuk mengubah struktur tabel MySQL.

Agar memudahkan dalam mempelajari query ALTER TABLE, saya akan membuat sebuah tabel sample: daftar_jurusan. Silahkan buka MySQL client, dan gunakan perintah query berikut jika anda ingin membuat tabel yang sama:

mysql> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mahasiswa          |
| mysql              |
| performance_schema |
| test               |
+--------------------+
5 rows in set (0.11 sec)

mysql> USE mahasiswa;
Database changed

mysql> CREATE TABLE daftar_jurusan ( kode_jurusan CHAR(5), 
nama_jurusan VARCHAR(20),alamat VARCHAR(100),
jumlah_mahasiswa SMALLINT );
Query OK, 0 rows affected (0.05 sec)

mysql> DESC daftar_jurusan;
+------------------+--------------+------+-----+---------+-------+
| Field            | Type         | Null | Key | Default | Extra |
+------------------+--------------+------+-----+---------+-------+
| kode_jurusan     | char(5)      | YES  |     | NULL    |       |
| nama_jurusan     | varchar(20)  | YES  |     | NULL    |       |
| alamat           | varchar(100) | YES  |     | NULL    |       |
| jumlah_mahasiswa | smallint(6)  | YES  |     | NULL    |       |
+------------------+--------------+------+-----+---------+-------+
4 rows in set (0.03 sec)

Query tersebut berisi perintah pembuatan tabel daftar_jurusan pada database mahasiswa. Jika anda belum membuat database, silahkan buat terlebih dahulu seperti pada Tutorial MySQL : Membuat dan Menghapus Database.


Cara Merubah Tipe Data Kolom MySQL

Sesaat setelah membuat tabel daftar_jurusan, saya berfikir untuk merubah tipe data pada kolom jumlah_mahasiswa dari SMALLINT menjadi MEDIUMINT agar dapat menampung lebih banyak nilai. Perubahan ini dapat dilakukan dengan mengunakan query ALTER…MODIFY sebagai berikut:

ALTER TABLE nama_tabel MODIFY nama_kolom tipe_data_baru;

Contoh query Alter…Modify:

mysql> ALTER TABLE daftar_jurusan MODIFY jumlah_mahasiswa MEDIUMINT;
Query OK, 0 rows affected (0.08 sec)
Records: 0  Duplicates: 0  Warnings: 0
mysql> DESC daftar_jurusan;
+------------------+--------------+------+-----+---------+-------+
| Field            | Type         | Null | Key | Default | Extra |
+------------------+--------------+------+-----+---------+-------+
| kode_jurusan     | char(5)      | YES  |     | NULL    |       |
| nama_jurusan     | varchar(20)  | YES  |     | NULL    |       |
| alamat           | varchar(100) | YES  |     | NULL    |       |
| jumlah_mahasiswa | mediumint(9) | YES  |     | NULL    |       |
+------------------+--------------+------+-----+---------+-------+
4 rows in set (0.01 sec)

Dari query DESC kita dapat melihat bahwa tipe data pada kolom jumlah_mahasiswa telah berubah menjadi MEDIUMINT.


Cara Merubah Nama Kolom Tabel MySQL

Untuk merubah nama kolom pada tabel yang sudah ada, dapat menggunakan perintah ALTER…CHANGE, dengan format query sebagai berikut:

ALTER TABLE nama_tabel CHANGE nama_kolom nama_kolom_baru tipe_data;

Katakan kita ingin merubah nama kolom alamat menjadi alamat_jurusan agar menjadi lebih spesifik, dapat dilakukan dengan query berikut:

Contoh query Alter…Change:

mysql> ALTER TABLE daftar_jurusan CHANGE alamat alamat_jurusan VARCHAR(100);
Query OK, 0 rows affected (0.06 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> DESC daftar_jurusan;
+------------------+--------------+------+-----+---------+-------+
| Field            | Type         | Null | Key | Default | Extra |
+------------------+--------------+------+-----+---------+-------+
| kode_jurusan     | char(5)      | YES  |     | NULL    |       |
| nama_jurusan     | varchar(20)  | YES  |     | NULL    |       |
| alamat_jurusan   | varchar(100) | YES  |     | NULL    |       |
| jumlah_mahasiswa | mediumint(9) | YES  |     | NULL    |       |
+------------------+--------------+------+-----+---------+-------+
4 rows in set (0.01 sec)

Cara Merubah Nama Tabel MySQL

Untuk beberapa kasus tertentu, mungkin saja kita memutuskan untuk merubah nama tabel MySQL. Untuk hal ini MySQL menyediakan query ALTER…RENAME TO dengan format query:

ALTER TABLE nama_tabel_lama RENAME TO nama_tabel_baru;

Kita contohkan merubah tabel daftar_jurusan menjadi tabel_jurusan, maka querynya:

Contoh query Alter…Rename To:

mysql> ALTER TABLE daftar_jurusan RENAME TO tabel_jurusan;
Query OK, 0 rows affected (0.06 sec)

mysql> DESC daftar_jurusan;
ERROR 1146 (42S02): Table 'mahasiswa.daftar_jurusan' doesn't exist

mysql> DESC tabel_jurusan;
+------------------+--------------+------+-----+---------+-------+
| Field            | Type         | Null | Key | Default | Extra |
+------------------+--------------+------+-----+---------+-------+
| kode_jurusan     | char(5)      | YES  |     | NULL    |       |
| nama_jurusan     | varchar(20)  | YES  |     | NULL    |       |
| alamat_jurusan   | varchar(100) | YES  |     | NULL    |       |
| jumlah_mahasiswa | mediumint(9) | YES  |     | NULL    |       |
+------------------+--------------+------+-----+---------+-------+
4 rows in set (0.00 sec)

Dapat kita lihat bahwa setelah merubah nama tabel menjadi tabel_jurusan, tabel daftar_jurusan sudah tidak terdapat lagi di dalam database mahasiswa.

Selain query ALTER…RENAME TO, terdapat juga perintah RENAME untuk merubah nama tabel,format querynya:

RENAME TABLE nama_tabel_lama TO nama_tabel_baru;

Mari kita rubah kembali nama tabel tabel_jurusan menjadi daftar_jurusan:

Contoh query Alter…Rename To:

mysql> RENAME TABLE tabel_jurusan TO daftar_jurusan;
Query OK, 0 rows affected (0.07 sec)

mysql> DESC tabel_jurusan;
ERROR 1146 (42S02): Table 'mahasiswa.tabel_jurusan' doesn't exist

mysql> DESC daftar_jurusan;
+------------------+--------------+------+-----+---------+-------+
| Field            | Type         | Null | Key | Default | Extra |
+------------------+--------------+------+-----+---------+-------+
| kode_jurusan     | char(5)      | YES  |     | NULL    |       |
| nama_jurusan     | varchar(20)  | YES  |     | NULL    |       |
| alamat_jurusan   | varchar(100) | YES  |     | NULL    |       |
| jumlah_mahasiswa | mediumint(9) | YES  |     | NULL    |       |
+------------------+--------------+------+-----+---------+-------+
4 rows in set (0.01 sec)

Cara Menambahkan Kolom Baru pada Tabel MySQL

Andaikan beberapa saat kemudian kita berfikir untuk menambahkan kolom yang berisi nama ketua jurusan ke dalam tabel daftar_jurusan, kita dapat saja menghapus tabel dan membuat ulang, namun dengan menggunakan query ALTER…ADD, menambahkan kolom baru dapat dilakukan dengan lebih mudah.

ALTER TABLE nama_tabel ADD nama_kolom_baru tipe_data;

Contoh query menambahkan kolom ketua_jurusan ke dalam tabel daftar_jurusan adalah:

Contoh query Alter…Add:

mysql> ALTER TABLE daftar_jurusan ADD ketua_jurusan VARCHAR(50);
Query OK, 0 rows affected (0.02 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> DESC daftar_jurusan;
+------------------+--------------+------+-----+---------+-------+
| Field            | Type         | Null | Key | Default | Extra |
+------------------+--------------+------+-----+---------+-------+
| kode_jurusan     | char(5)      | YES  |     | NULL    |       |
| nama_jurusan     | varchar(20)  | YES  |     | NULL    |       |
| alamat_jurusan   | varchar(100) | YES  |     | NULL    |       |
| jumlah_mahasiswa | mediumint(9) | YES  |     | NULL    |       |
| ketua_jurusan    | varchar(50)  | YES  |     | NULL    |       |
+------------------+--------------+------+-----+---------+-------+
5 rows in set (0.01 sec)

Cara Menghapus Kolom Tabel MySQL

Kebalikan dari menambahkan kolom baru, query ALTER…DROP dapat digunakan untuk menghapus sebuah kolom dari tabel MySQL.

ALTER TABLE nama_tabel DROP nama_kolom;

Mari kita contohkan dengan menghapus kolom ketua_jurusan dari tabel daftar_jurusan:

Contoh query Alter…Drop:

mysql> ALTER TABLE daftar_jurusan DROP ketua_jurusan;
Query OK, 0 rows affected (0.04 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> DESC daftar_jurusan;
+------------------+--------------+------+-----+---------+-------+
| Field            | Type         | Null | Key | Default | Extra |
+------------------+--------------+------+-----+---------+-------+
| kode_jurusan     | char(5)      | YES  |     | NULL    |       |
| nama_jurusan     | varchar(20)  | YES  |     | NULL    |       |
| alamat_jurusan   | varchar(100) | YES  |     | NULL    |       |
| jumlah_mahasiswa | mediumint(9) | YES  |     | NULL    |       |
+------------------+--------------+------+-----+---------+-------+
4 rows in set (0.01 sec)

Cara Merubah Tipe Data Table (Table Engine) MySQL

MySQL menyediakan beberapa tipe data untuk beberapa keperluan, seperti tipe data (disebut juga dengan engine tabel) MyISAM untuk tabel yang dioptimalisasikan untuk keperluan pembacaan yang lebih sering, atau tipe data InnoDB untuk tabel yang memerlukan transaksi.

Perubahan tipe data dari MyISAM ke InnoDB atau sebaliknya dapat menggunakan perintah ALTER…ENGINE:

ALTER TABLE nama_tabel ENGINE = tipe_tabel;

Dalam MySQL versi 5.5 yang saya gunakan pada tutorial ini, default enginenya adalah InnoDB, hal ini berbeda jika dibandingkan dengan versi MySQL sebelumnya yang menggunakan tipe tabel MyISAM sebagai default.

Pada contoh query dibawah ini kita akan merubah tipe data tabel daftar_jurusan dari InnoDB menjadi MyISAM.

Contoh query Alter…Engine:

mysql> SHOW TABLE STATUS WHERE NAME='daftar_jurusan' \G;

***************************1.row***************************
Name: daftar_jurusan
Engine: InnoDB
Version: 10
Row_format: Compact
Rows: 0
Avg_row_length: 0
Data_length: 16384
Max_data_length: 0
Index_length: 0
Data_free: 9437184
Auto_increment: NULL
Create_time: 2013-04-14 21:20:02
Update_time: NULL
Check_time: NULL
Collation: latin1_swedish_ci
Checksum: NULL
Create_options:
Comment:
1 row in set (0.00 sec)
ERROR:
No query specified

mysql> ALTER TABLE daftar_jurusan ENGINE = MyISAM;
Query OK, 0 rows affected (0.06 sec)
Records: 0  Duplicates: 0  Warnings: 0

mysql> SHOW TABLE STATUS WHERE NAME='daftar_jurusan' \G;

***************************1.row***************************
Name: daftar_jurusan
Engine: MyISAM
Version: 10
Row_format: Dynamic
Rows: 0
Avg_row_length: 0
Data_length: 0
Max_data_length: 281474976710655
Index_length: 1024
Data_free: 0
Auto_increment: NULL
Create_time: 2013-04-14 22:43:29
Update_time: 2013-04-14 22:43:29
Check_time: NULL
Collation: latin1_swedish_ci
Checksum: NULL
Create_options:
Comment:
1 row in set (0.00 sec)
ERROR:
No query specified
mysql>

Query SHOW TABLE STATUS digunakan untuk melihat engine apa yang digunakan dalam sebuah tabel. Penjelasan tentang tipe tabel akan kita pelajari pada tutorial tersendiri.


Dalam tutorial belajar MySQL kali ini kita telah membahas tentang query ALTER TABLE yang digunakan untuk mengubah struktur tabel di dalam MySQL. Dalam tutorial selanjutnya, kita akan mempelajari Cara Menambahkan data (Query INSERT) di dalam MySQL