SQL Command

Database Management System

Lesson – 17

SQL (Structured Query Language)

এই লেসনে SQL ( Structured Query Language) এর বিভিন্ন কমান্ড ব্যবহার করে রিলেশন তৈরি করব এবং সিলেবাসের কমান্ডগুলি রান করাব ।

MySQLকীভাবে রান করাবে ?

Stare->MySQL8.0 Command Line Client ক্লিক করলে Password দেয়ার জন্য একটি Window খুলবে সেখানে root(যদি Password পরিবর্তন না করা হয়) টাইপ করলে mysql> প্রম্পট আসবে । এখানে নির্দিষ্ট ডেটাবেস কে সিলেক্ট করতে হবে এবং প্রয়োজনীয় কমান্ড দিতে হবে ।

DDL Command

নূতন ডেটাবেস তৈরি করার কমান্ড হল-

create  database <database Name>;

কোনো Database কে ব্যবহার করার কমান্ড হল –

Use <Database Name>

কতগুলি Database আছে তা দেখার কমান্ড হল –

Show Databases;

Database এর মধ্যে কতগুলি Table  আছে তা দেখার কমান্ড হল –

Show Tables;

কোন Table  এর Structure কমান্ড হল –

Desc <Table Name> / Describe<Table Name>;

ডেটাবেস ডিলিট করার কমান্ড হল-

Drop Database <Database Name>

Student (Roll, Name, Class) টেবিলটি তৈরি কর ।

Create table Student(Roll int Primary Key, Name char(20), Class char(3));

Student (Roll, Name, Class) টেবিলটিতৈ DOB  নামে নূতন ফিল্ড যুক্ত কর ।

Alter Table Student Add(DOB date);

Student (Roll, Name, Class,DOB) টেবিলটিতৈ Marks  নামে নূতন ফিল্ড যুক্ত কর ।

Alter Table Student Add(Marks int);

Student (Roll, Name, Class, DOB, Marks) টেবিলটির Marks ফিল্ডের নাম পরিবর্তন করে Obtain_Marks কর ।

Alter Table Student Rename Column Marks to Obtain_Marks;

Student (Roll, Name, Class, DOB, Obtain_Marks) টেবিলটির DOB ফিল্ডের নাম পরিবর্তন করে Date Of Birth কর

Alter Table Student Rename Column DOB to Date-Of-Birth;

Student টেবিলটির নাম পরিবর্তন করে Student_Dtl কর ।

Alter Table Student Rename to Student_Dtl;

Student_Dtl (Roll, Name, Class, Date Of Birth , Obtain_Marks) টেবিলটিতৈ একটি নূতন রেকর্ড যুক্ত কর ।

Insert into table Student Values(1, ‘A’, ‘XII’, ‘12.12.2008, 450);

Student_Dtl (Roll, Name, Class, Date Of Birth , Obtain_Marks) টেবিলটিতৈ আরো একটি নূতন রেকর্ড যুক্ত কর ।

Insert into table Student Values(2, ‘B’, ‘XII’, ‘12.08.2008, 400);

Student_Dtl (Roll, Name, Class, Date Of Birth , Obtain_Marks) টেবিলটির Date Of Birth  ফিল্ডটি ডিলিট কর ।

Alter Table student Drop column Date Of Birth ;

Student (Roll, Name, Class, Obtain_Marks) টেবিলের সব রেকর্ড গুলিকে একসাথে ডিলিট কর ।

Truncate table student;

Student (Roll, Name, Class, Date Of Birth , Obtain_Marks) টেবিল টিকে ডিলিট কর ।

Drop table student;

DML Command এর Practical

Leave a Reply