Home  >  Article  >  Database  >  l数据库基本语句

l数据库基本语句

WBOY
WBOYOriginal
2016-06-07 15:22:411444browse

1.数据库备份 ---创建 备份数据的 device USE master EXEC sp_addumpdevice 'disk', 'testBack', 'c:\MyNwind_1.dat' testBack:磁盘备份设备 物理名称: c:\MyNwind_1.dat ---开始 备份 BACKUP DATABASE dbname TO testBack (sa用户登录) 2.分离数据 use ma

1.数据库备份

---创建 备份数据的 device
USE master
EXEC sp_addumpdevice 'disk', 'testBack', 'c:\MyNwind_1.dat'

testBack:磁盘备份设备

物理名称:c:\MyNwind_1.dat

---开始 备份
BACKUP DATABASE dbname TO testBack

(sa用户登录)

2.分离数据

use master
sp_detach_db testdb2

3.附加数据库

EXEC sp_attach_db @dbname = N'testdb2',
@filename1 = N'd:\testdb2.mdf',
@filename2 = N'd:\testdb2_1.ldf'

4.修改数据库的名字

use master

sp_renamedb 'olddbname', 'newdbname'

5.列出数据库里所有的表名

select name from sysobjects where type='U'

6.说明:列出表里的所有的列名

select name from syscolumns where id=object_id('表名')

7.重建索引


DBCC dbREINDEX('表名字','索引名字')

DBCC INDEXDEFRAG('数据库名字','表名字','索引名字')


未完待续!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:hive查询hbaseNext article:ReportingServicetextbox换行