Learning Mysql



Download 4.24 Mb.
View original pdf
Page167/366
Date04.08.2023
Size4.24 Mb.
#61806
1   ...   163   164   165   166   167   168   169   170   ...   366
Learning MySQL
Creating Tables | 185

mysql> SHOW VARIABLES LIKE 'c%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
| collation_connection | latin1_swedish_ci |
| collation_database | latin1_swedish_ci |
| collation_server | latin1_swedish_ci |
+--------------------------+----------------------------+
14 rows inset sec)
When you’re creating a database, you can set the default character set and sort order for the database and its tables. For example, if you want to use the latin1
character set and the latin1_swedish_cs
(case-sensitive) collation order, you would write:
mysql> CREATE DATABASE rose DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_cs;
Query OK, 1 row affected (0.00 sec)
As we’ve previously discussed, there’s no need to do this if you’ve installed your MySQL
correctly for your language and region, and if you’re not planning on internationalizing your application. You can also control the character set and collation for individual tables or columns, but we won’t go into the detail of how to do that here.
Other Features
This section briefly describes other features of the MySQL CREATE TABLE
statement. It includes an example using the IF NOT EXISTS
feature, and a list of advanced features and whereto find more about them in this book.
You can use the IF NOT EXISTS
keyword phrase when creating a table, and it works much as it does for databases. Here’s an example that won’t report an error even when the artist table exists:
mysql> CREATE TABLE IF NOT EXISTS artist (

Download 4.24 Mb.

Share with your friends:
1   ...   163   164   165   166   167   168   169   170   ...   366




The database is protected by copyright ©ininet.org 2024
send message

    Main page