STUDY THIS STRICTLY STEP BY STEP
===================================================
1 - use nareshitdb;
2 - sp_helpdb; /* show databases*/
3- create table studBatch01(
id int,
name varchar(255),
course varchar(255),
address varchar(255),
fees int
);
4 - select * from INFORMATION_SCHEMA.TABLES; /*USE FOR SHOW TABLES*/
5 - exec sp_help 'students'; /* use for show table structures*/
6 - insert into studBatch01 values(5, 'Akash kumar','Spring Boot', 'Varanasi','15000');
7 - select * from studBatch01;
8 - update studBatch01 set name ='Prince' where course ='c# language';
9 - alter table studBatch01
alter column id int not null;
10 - alter table studBatch01
alter column name varchar(225) not null;
11 - alter table studBatch01
alter column course varchar(225) not null;
12 - alter table studBatch01
alter column address varchar(225) not null;
13 - alter table studBatch01
alter column fees int not null;
14 - alter table studBatch01
add CONSTRAINT UK_studBatch01 unique (id);
15 - alter table studBatch01
add CONSTRAINT PK_studBatch01 PRIMARY KEY (id);
16 - exec sp_rename 'studBatch01', 'Studentone';
/*change the table names or Rename tables*/
17 - select * from information_schema.tables;
18 - exec sp_rename 'studentone', 'studBatch01';


No comments:
Post a Comment