如何使用sqlcmd创建数据库

编程入门 行业动态 更新时间:2024-10-15 04:25:37
本文介绍了如何使用sqlcmd创建数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个 .sql 脚本,我想用它构建一个数据库.如何在 sqlcmd 中做到这一点?我知道这就像:

I have a .sql script and I want to build a database from it. How to do it in sqlcmd? I know it's like:

CREATE DATABASE dbName GO

但是如何指定 .sql 脚本和位置来构建数据库?

But how to specify the .sql script and location to build the database?

推荐答案

使用 @Jeremiah Peschka's answer 提供sqlcmd 实用程序以及要执行的脚本.

Use @Jeremiah Peschka's answer to supply the sqlcmd utility with the script to execute.

至于新创建的数据库的位置,可以指定为创建数据库命令:

As for the location for the newly created database, it can be specified as part of the CREATE DATABASE command:

CREATE DATABASE dbName ON ( NAME = dbName_dat, FILENAME = 'D:\path\to\dbName.mdf' ) LOG ON ( NAME = dbName_log, FILENAME = 'D:\path\to\dbName.ldf' )

正如您从链接的文章中看到的,您还可以指定其他属性,例如初始大小、最大大小等.

As you can see from the linked article, you can specify other properties as well, like initial size, maximum size etc.

更多推荐

如何使用sqlcmd创建数据库

本文发布于:2023-11-02 04:00:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1551310.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   数据库   sqlcmd

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!