728x90
SMALL
#SQL
#SQL Server
Creating a database
- The database is created with create database.
Create a database named shop.
create database shop;
If you name the database or have special characters, enclose it in double quotes or parentheses.
create database "shop.shop";
create database [shop.shop];
Delete database
The database is deleted with the drop database.
drop database shop;
If you name the database or have special characters, enclose it in double quotes or parentheses.
drop database "shop.shop";
drop database [shop.shop];
Database usage
- It is use to specify the database to be worked on.
Use the shop database.
use shop;
Database name change
Rename the database shop to shopshop.
alter database shop modify name = shopshop;
TIP.
In the case of a database that is in operation, it is better to do the following.
alter database shop set single_user with rollback immediate;
go
alter database shop modify name = shopshop;
go
alter database shopshop set multi_user;
Query database list
Method.1
execute sp_helpdb;
Method.2
select name from sys.databases;
TIP.
sys.databases is a system view of the master database.
728x90
LIST
'SQL server' 카테고리의 다른 글
[SQL] SQL Server/Schema/Create, Browse, Modify, Delete (0) | 2022.08.09 |
---|