টেবিল তৈরি এবং ডেটা ইনসার্ট
mysql> create table DemoTable1859 ( Id int ); Query OK, 0 rows affected (0.00 sec)
mysql> insert into DemoTable1859 values(101); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1859 values(102); Query OK, 1 row affected (0.00 sec)
রিনেমের আগে
mysql> select * from DemoTable1859;
+------+ | Id | +------+ | 101 | | 102 | +------+ 2 rows in set (0.00 sec)
রিনেম করার স্টোরড প্রোসিজার
mysql> delimiter //
mysql> create procedure alter_table_name_sp()
begin
alter table DemoTable1859 rename exampleTable;
end
//
Query OK, 0 rows affected (0.00 sec)
mysql> delimiter ;
প্রোসিজার কল এবং যাচাই
mysql> call alter_table_name_sp(); Query OK, 0 rows affected (0.00 sec)
mysql> select * from exampleTable;
+------+ | Id | +------+ | 101 | | 102 | +------+ 2 rows in set (0.00 sec)
দ্রষ্টব্য: ALTER TABLE ... RENAME DDL স্টেটমেন্ট, যা অটো-কমিট করে। প্রোসিজারের ভিতর DDL ব্যবহার করা সাধারণত অপ্রস্তুত, কিন্তু সম্ভব। প্রোডাকশনে সতর্কতা অবলম্বন করুন।