STUDY THIS STRICTILY STEP BY STEP
====================================================================
1 - use nareshitdb;
2- sp_helpdb; /* Purpose: Provides detailed information about databases on the SQL Server instance.
show databases*/
3 - select * from INFORMATION_SCHEMA.TABLES;
/*check the database and their tables*/
4 - exec sp_help 'students'; /* use for show table structures*/
5 - select * from students;
6 - alter table students
alter column name varchar(255) not null
7 - alter table students
add fees int null default 0;
8 - alter table students
alter column course varchar(255) not null;
9 - alter table students
alter column address varchar(255) not null;
10 - alter table students
add UNIQUE (id);
/*alter table studBatch01
add CONSTRAINT UK_studBatch01 unique (id); */
11 - insert into students values('5', 'abhinav', 'Java fullstack','Madhya Pradesh');
12 - alter table students
add primary key (id);
/*alter table studBatch01
add CONSTRAINT PK_studBatch01 PRIMARY KEY (id); */
13 - exec sp_rename 'studBatch01', 'Studentone';
/*change the table names or Rename tables : exec -> EXCUTE and sp_remane-> stored procedure*/
14 - select * from information_schema.tables;
15 - exec sp_rename 'studentone', 'studBatch01';


No comments:
Post a Comment