Mysql your visual blueprint for creating open source databases- P5
Số trang: 20
Loại file: pdf
Dung lượng: 636.54 KB
Lượt xem: 12
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- P5: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- P5 MODIFY TABLES 3 If you change the column order using ALTER TABLE, it may create potential problems with applications that were built to work with the table. For example, suppose an application used the following command to add a record to a table: Example: INSERT INTO links VALUES(Netscape, http://www.netscape.com/, Netscape Corp.); This command adds a row to the table, specifying values for each of the three columns. While this command will work with the current version of the links table, it does not specify the columns for the insert and thus relies on the current column order. If you have changed the column order using the CHANGE or ADD COLUMN features of ALTER TABLE, the INSERT command will fail, or worse, may insert incorrect data into the table. Applications that retrieve data without using column names can run into the same problem. While the best practice is to specify column names in all queries, you can avoid these potential issues if you avoid changing the order of table columns. If your applications do use column names, of course, a renamed column could cause an error. Keep both of these issues in mind any time you modify a working table. See Chapter 4 for more information about the INSERT command in MySQL.‹ Type ALTER TABLE links › Type CHANGE url link ˇ Type DESCRIBE links; and s This displays the columnand press Enter. VARCHAR(255); and press press Enter. list again. Note that the new Enter. name is now listed for thes The MySQL monitor link column.prompts for the next line. s MySQL now changes the name of the column. 67 MySQLCHANGE A COLUMN TYPE keyword is supported only in MySQL 3.22 and later. TheW hile it is important to choose each columns type and attributes carefully when creating a table, following example makes another change to the description you can change a columns type using ALTER column using MODIFY:TABLE. The basic syntax for this is similar to renaming a ALTER TABLE linkstable, using the CHANGE keyword. For example, the MODIFY description VARCHAR(150);following command changes the description field in thelinks table to a VARCHAR(200) column: When you change a columns type, MySQL makes an effort to preserve the data in existing rows as much as possibleALTER TABLE links CHANGE and convert it to the new type. If you change a tables type description description VARCHAR(200); to a type that stores less data — for example, changing aTo avoid renaming the table when using CHANGE, specify TEXT column to a VARCHAR column — the values will bethe same name for the old and new names. You can also truncated to fit in the new size. Changing the columns typespecify any attributes of the column you want to change back to its original type will not restore the data.with the CHANGE keyword. For example, you can specify the As when creating a table or adding a column, the MySQLNULL or NOT NULL attributes or specify a default value server may not allow some changes. If the table currentlyusing the DEFAULT keyword. Include these items after the has one or more va ...
Nội dung trích xuất từ tài liệu:
Mysql your visual blueprint for creating open source databases- P5 MODIFY TABLES 3 If you change the column order using ALTER TABLE, it may create potential problems with applications that were built to work with the table. For example, suppose an application used the following command to add a record to a table: Example: INSERT INTO links VALUES(Netscape, http://www.netscape.com/, Netscape Corp.); This command adds a row to the table, specifying values for each of the three columns. While this command will work with the current version of the links table, it does not specify the columns for the insert and thus relies on the current column order. If you have changed the column order using the CHANGE or ADD COLUMN features of ALTER TABLE, the INSERT command will fail, or worse, may insert incorrect data into the table. Applications that retrieve data without using column names can run into the same problem. While the best practice is to specify column names in all queries, you can avoid these potential issues if you avoid changing the order of table columns. If your applications do use column names, of course, a renamed column could cause an error. Keep both of these issues in mind any time you modify a working table. See Chapter 4 for more information about the INSERT command in MySQL.‹ Type ALTER TABLE links › Type CHANGE url link ˇ Type DESCRIBE links; and s This displays the columnand press Enter. VARCHAR(255); and press press Enter. list again. Note that the new Enter. name is now listed for thes The MySQL monitor link column.prompts for the next line. s MySQL now changes the name of the column. 67 MySQLCHANGE A COLUMN TYPE keyword is supported only in MySQL 3.22 and later. TheW hile it is important to choose each columns type and attributes carefully when creating a table, following example makes another change to the description you can change a columns type using ALTER column using MODIFY:TABLE. The basic syntax for this is similar to renaming a ALTER TABLE linkstable, using the CHANGE keyword. For example, the MODIFY description VARCHAR(150);following command changes the description field in thelinks table to a VARCHAR(200) column: When you change a columns type, MySQL makes an effort to preserve the data in existing rows as much as possibleALTER TABLE links CHANGE and convert it to the new type. If you change a tables type description description VARCHAR(200); to a type that stores less data — for example, changing aTo avoid renaming the table when using CHANGE, specify TEXT column to a VARCHAR column — the values will bethe same name for the old and new names. You can also truncated to fit in the new size. Changing the columns typespecify any attributes of the column you want to change back to its original type will not restore the data.with the CHANGE keyword. For example, you can specify the As when creating a table or adding a column, the MySQLNULL or NOT NULL attributes or specify a default value server may not allow some changes. If the table currentlyusing the DEFAULT keyword. Include these items after the has one or more va ...
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 397 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 240 0 0 -
Giáo trình Cơ sở dữ liệu: Phần 2 - Đại học Kinh tế TP. HCM
115 trang 175 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 117 1 0 -
Giáo trình cơ sở dữ liệu quan hệ_3
26 trang 105 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 99 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 64 0 0