Interview Questions and answers - SQL Server Day 8

Question: What is schema in SQL Server? How can we create the schema in SQL Server?

Answer: Schema introduced in SQL Server 2005 which is used for separation, Management and Ownership of the database object. Schema is a distinct namespace that is used to store the database object. It removes the tight coupling of database objects and owners to improve the security administration of database objects.

Create schema using wizard 

Create schema using query

USE [Test]
--Create Schema MySchema
CREATE SCHEMA [MySchema] AUTHORIZATION [dilip] --dilip is the owner (database user)

Question: How to change the schema of the table in SQL Server?

Answer: Suppose we have a table Codefari which has default schema [dbo] and we have to transfer it in schema [blog], the following query may help you.

TRANSFER dbo.Codefari

Question: How to drop schema in SQL Server?
Answer: If we have permission then using the following query we can drop the schema.

DROP Schema Blog

Related Posts

Fatal Error: Peer authentication failed for user "postgres", when trying to get pgsql working with rails.

Problem: Sometimes, we get the following error when trying to make a connection in Rails.  FATAL ERROR: Peer authentication failed for us...