কম্পিউটার টিউটোরিয়াল

MySQL ডেটাবেস টেবিলের ইঞ্জিন কীভাবে পরিবর্তন করবেন?

প্রথমে জানুন আপনার টেবিল কোন স্টোরেজ ইঞ্জিন ব্যবহার করছে—InnoDB নাকি MyISAM। এজন্য information_schema.tables-এর ENGINE কলাম ব্যবহার করুন।

বর্তমান ইঞ্জিন জানার সিনট্যাক্স

SELECT ENGINE FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'yourDatabaseName' AND TABLE_NAME = 'yourTableName';

উদাহরণ

একটি টেবিল তৈরি করি:

mysql> create table StudentInformations 
    -> ( 
    -> StudentId int not null auto_increment, 
    -> StudentFirstName varchar(20), 
    -> StudentLastName varchar(20), 
    -> Primary Key(StudentId) 
    -> ); Query OK, 0 rows affected (0.57 sec)

এখন ডেটাবেস 'test'-এ এই টেবিলের ইঞ্জিন জানুন:

mysql> select engine from information_schema.tables 
    -> where table_schema = 'test' 
    -> and table_name = 'StudentInformations';

আউটপুট

+--------+
| ENGINE |
+--------+
| InnoDB |
+--------+
1 row in set (0.05 sec)

ইঞ্জিন পরিবর্তন করুন

ALTER TABLE কমান্ড দিয়ে ইঞ্জিন পরিবর্তন করা যায়:

ALTER TABLE yourTableName ENGINE = 'yourEngineName';

InnoDB থেকে MyISAM-এ রূপান্তর:

mysql> alter table StudentInformations ENGINE = 'MyISAM'; 
Query OK, 6 rows affected (1.84 sec) 
Records - 6 Duplicates - 0 Warnings - 0
নোট: আউটপুটে "6 rows affected" দেখা যাচ্ছে কারণ টেবিলে ৬টি রো আছে।

পরিবর্তন যাচাই করুন

mysql> select engine from information_schema.tables 
-> where table_schema = 'test' 
-> and table_name = 'StudentInformations';

আউটপুট

+--------+
| ENGINE |
+--------+
| MyISAM |
+--------+
1 row in set (0.00 sec)
  1. MySQL টেবিলের কলামের ডেটা টাইপ পরিবর্তন করুন

  2. MySQL-এ টেবিলের কাঠামো ক্লোন করা

  3. MySQL-এ টেবিল খালি কিনা চেক করা (SELECT রিটার্ন খালি সেট)

  4. MySQL-এ ALTER TABLE ... ENGINE দিয়ে স্টোরেজ ইঞ্জিন পরিবর্তন করা