Test your skills through the online practice test: MySQL Quiz Online Practice Test

Related differences

Ques 86. How To Add a New Column to an Existing Table in MySQL?

If you have an existing table with existing data rows, and want to add a new column to that table, you can use the "ALTER TABLE ... ADD COLUMN" statement. The tutorial script below shows you a good example:

mysql> ALTER TABLE test ADD COLUMN author VARCHAR(40);
Query OK, 1 row affected (0.18 sec)
Records: 1 Duplicates: 0 Warnings: 0

Is it helpful? Add Comment View Comments
 

Ques 87. How To Enter Characters as HEX Numbers?

If you want to enter characters as HEX numbers, you can quote HEX numbers with single quotes and a prefix of (X), or just prefix HEX numbers with (0x). A HEX number string will be automatically converted into a character string, if the expression context is a string. Here are some good examples:

SELECT X'313233' FROM DUAL;
123

SELECT 0x414243 FROM DUAL;
ABC

SELECT 0x46594963656E7465722E636F6D FROM DUAL; WithoutBook.com

Is it helpful? Add Comment View Comments
 

Ques 88. How To Delete an Existing Column in a Table?

If you have an existing column in a table and you do not need that column any more, you can delete it with "ALTER TABLE ... DROP COLUMN" statement. Here is a tutorial script to delete an existing column:

mysql> ALTER TABLE test DROP COLUMN create_date;
Query OK, 1 row affected (0.48 sec)
Records: 1 Duplicates: 0 Warnings: 0

Is it helpful? Add Comment View Comments
 

Ques 89. How To Enter Numeric Values as HEX Numbers?

If you want to enter numeric values as HEX numbers, you can quote HEX numbers with single quotes and a prefix of (X), or just prefix HEX numbers with (0x). A HEX number string will be automatically converted into a numeric value, if the expression context is a numeric value. Here are some good examples:

SELECT X'10' + 16 FROM DUAL;
32

SELECT 0x1000 + 0 FROM DUAL;
4096

Is it helpful? Add Comment View Comments
 

Ques 90. How To Rename an Existing Column in a Table?

If you have an existing column in a table and you want to change the column name, you can use the "ALTER TABLE ... CHANGE" statement. This statement allows you to change the name of a column, and its definition. The tutorial script below gives you a good example:

mysql> ALTER TABLE test CHANGE COLUMN subject
title VARCHAR(60);
Query OK, 1 row affected (0.51 sec)
Records: 1 Duplicates: 0 Warnings: 0

Is it helpful? Add Comment View Comments
 

Most helpful rated by users: