Mysql your visual blueprint for creating open source databases- P4
Số trang: 20
Loại file: pdf
Dung lượng: 596.20 KB
Lượt xem: 21
Lượt tải: 0
Xem trước 2 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
Mysql your visual blueprint for creating open source databases- P4:The show tables command displays a list of tables available in the currently selected database. You can use this command when you are unsure of the exact name of a table within the database.
Nội dung trích xuất từ tài liệu:
Mysql your visual blueprint for creating open source databases- P4 MANAGE DATABASES AND TABLES 2 If you are not sure what length to use for a CHAR or VARCHAR column, specify a value large enough to store a typical value. You can always change the length later. You can also change VARCHAR columns to TEXT columns without losing data. This is explained in Chapter 3. The MySQL server may automatically change the type of some of your columns if there is a conflict between them. In particular, if you use fixed-length CHAR columns and at least one variable-length VARCHAR or TEXT column, the entire row must be variable length, so your CHAR columns are converted to VARCHAR. In addition, the server automatically changes VARCHAR columns with a length of one to three characters to CHAR columns, because it is not practical to use variable length when the column is this small. While it is important to choose the correct column types when you create a table, after you have created it, you can work with VARCHAR and CHAR columns in exactly the same ways. TEXT columns also work in most of the same ways, except that you cannot use the entire body of a TEXT field as an index.s The MySQL monitor ˇ Type description TEXT ); s The table is now created. s The columns you createdprompts for another line. and press Enter. for this table are displayed. Á To verify that the› Type url VARCHAR(255), Note: If you want to add additional command worked, typeand press Enter. fields, include them before the SHOW COLUMNS FROM links; closing parenthesis. and press Enter. 47 MySQLUSING SETS AND ENUMERATIONS the table. You can look at an ENUM column as a list of flags,S ets and enumerations are different from normal text columns in that they are limited to a specific list of each of which can be assigned or not assigned to an item. values. You can use these columns whenever you In the music catalog example, an ENUM column would beneed to assign categories to the items in a table. For ideal to store the media the music is available on:example, suppose you were using a database table to media ENUM(CD,DVD,LP,Cassette)catalog music recordings. You could use a SET column tostore the category of music that each recording contains: Although you could use separate columns to achieve the same effect, ENUM columns are convenient because theycategory SET(rock, pop, blues, can be assigned values as a single unit. They are also storedcountry, dance) on the server in a highly efficient way, using only one bit perThe one potential disadvantage of a SET column is that item, and are thus especially useful when you are storingeach item can have only one value. Anything that fits more many rows of data in a table.than one category could only be listed in one. This is where Because ENUM and SET columns can have a large numberENUM columns are useful. of possible values, you may need to split the columnWith an ENUM column, each item can be assigned any specification into two or more lines when you create thenumber of values from the list you specify when you create table. USING SETS AND ENUMERATIONS⁄ From the MySQL monitor, ¤ Type CREATE TABLE music ( s The MySQL monitor ‹ Type title VARCHAR(100),type USE testdb; and press and press Enter. prompts for the next line. and press Enter.Enter. ...
Nội dung trích xuất từ tài liệu:
Mysql your visual blueprint for creating open source databases- P4 MANAGE DATABASES AND TABLES 2 If you are not sure what length to use for a CHAR or VARCHAR column, specify a value large enough to store a typical value. You can always change the length later. You can also change VARCHAR columns to TEXT columns without losing data. This is explained in Chapter 3. The MySQL server may automatically change the type of some of your columns if there is a conflict between them. In particular, if you use fixed-length CHAR columns and at least one variable-length VARCHAR or TEXT column, the entire row must be variable length, so your CHAR columns are converted to VARCHAR. In addition, the server automatically changes VARCHAR columns with a length of one to three characters to CHAR columns, because it is not practical to use variable length when the column is this small. While it is important to choose the correct column types when you create a table, after you have created it, you can work with VARCHAR and CHAR columns in exactly the same ways. TEXT columns also work in most of the same ways, except that you cannot use the entire body of a TEXT field as an index.s The MySQL monitor ˇ Type description TEXT ); s The table is now created. s The columns you createdprompts for another line. and press Enter. for this table are displayed. Á To verify that the› Type url VARCHAR(255), Note: If you want to add additional command worked, typeand press Enter. fields, include them before the SHOW COLUMNS FROM links; closing parenthesis. and press Enter. 47 MySQLUSING SETS AND ENUMERATIONS the table. You can look at an ENUM column as a list of flags,S ets and enumerations are different from normal text columns in that they are limited to a specific list of each of which can be assigned or not assigned to an item. values. You can use these columns whenever you In the music catalog example, an ENUM column would beneed to assign categories to the items in a table. For ideal to store the media the music is available on:example, suppose you were using a database table to media ENUM(CD,DVD,LP,Cassette)catalog music recordings. You could use a SET column tostore the category of music that each recording contains: Although you could use separate columns to achieve the same effect, ENUM columns are convenient because theycategory SET(rock, pop, blues, can be assigned values as a single unit. They are also storedcountry, dance) on the server in a highly efficient way, using only one bit perThe one potential disadvantage of a SET column is that item, and are thus especially useful when you are storingeach item can have only one value. Anything that fits more many rows of data in a table.than one category could only be listed in one. This is where Because ENUM and SET columns can have a large numberENUM columns are useful. of possible values, you may need to split the columnWith an ENUM column, each item can be assigned any specification into two or more lines when you create thenumber of values from the list you specify when you create table. USING SETS AND ENUMERATIONS⁄ From the MySQL monitor, ¤ Type CREATE TABLE music ( s The MySQL monitor ‹ Type title VARCHAR(100),type USE testdb; and press and press Enter. prompts for the next line. and press Enter.Enter. ...
Tìm kiếm theo từ khóa liên quan:
giáo trình cơ sở dữ liệu quản trị cơ sở dữ liệu MySQL cơ bản bảo mật cơ sở dữ liệu giáo trình sql cơ bảnGợi ý tài liệu liên quan:
-
62 trang 394 3 0
-
Giáo trình Cơ sở dữ liệu: Phần 2 - TS. Nguyễn Hoàng Sơn
158 trang 284 0 0 -
Đề cương chi tiết học phần Quản trị cơ sở dữ liệu (Database Management Systems - DBMS)
14 trang 238 0 0 -
Giáo trình Cơ sở dữ liệu: Phần 2 - Đại học Kinh tế TP. HCM
115 trang 174 0 0 -
Giáo trình Cơ sở dữ liệu: Phần 1 - Sở Bưu chính Viễn Thông TP Hà Nội
48 trang 166 1 0 -
Giáo Trình về Cơ Sở Dữ Liệu - Phan Tấn Quốc
114 trang 116 1 0 -
Giáo trình cơ sở dữ liệu quan hệ_3
26 trang 103 0 0 -
Giáo trình Cơ sở dữ liệu (Ngành: Công nghệ thông tin - Trung cấp) - Trường Cao đẳng Xây dựng số 1
49 trang 98 0 0 -
Giáo trình: Hệ quản trị cơ sở dữ liệu - Nguyễn Trần Quốc Vinh
217 trang 78 0 0 -
Tiểu Luận Chương Trình Quản Lí Học Phí Trường THPT
18 trang 61 0 0