SQL Create Database
Jun 07, 2016 pm 05:42 PMSQL SERVER -- 由于最近時間充裕,針對于常用的Create database 做一下整理。 -- 以下是針對數(shù)據(jù)庫創(chuàng)建的做的一些實例 -- Create Database -- 1 . 該實例為創(chuàng)建普通的數(shù)據(jù)和日志文件(●- ●) Use mastergoCREATE DATABASE common_dbON ( NAME = common,FILEN
SQL SERVER
--由于最近時間充裕,針對于常用的Create database 做一下整理。
-- 以下是針對數(shù)據(jù)庫創(chuàng)建的做的一些實例
-- Create Database
--1. 該實例為創(chuàng)建普通的數(shù)據(jù)和日志文件(●-●)
Use master
go
CREATE DATABASE common_db
ON
( NAME = common,
FILENAME = ,
SIZE = 10,--初始大小 由于沒有填寫MB或者KB, 此種情況會默認(rèn)用MB
MAXSIZE = 50, -- 最大數(shù)據(jù)庫容量
FILEGROWTH = 5 -- 數(shù)據(jù)庫的增長值/率
)
LOG ON
( NAME = Sales_log,
FILENAME = ,
SIZE = 5,
MAXSIZE = 25,
FILEGROWTH = 5) ;
GO
--2.以下為多個數(shù)據(jù)和事務(wù)日志文件的創(chuàng)建
--如果沒有primary 數(shù)據(jù)庫就會默認(rèn)第一個文件為主文件
Create Database CommonFiles_DB
ON
Primary -- 關(guān)鍵字primary 即這個為主數(shù)據(jù)文件
(
NAME =COMMONFILE,
FILENAME=,
SIZE=10,
MAXSIZE= 100,
FILEGROWTH=10
),
(
NAME=commonfile_ex,
FILENAME=,
SIZE=10,
MAXSIZE=100,
FILEGROWTH=10
),
(
NAME= commonfile_expect,
FILENAME=,
SIZE=10,
MAXSIZE=100,
FILEGROWTH=10
)
LOG ON -- 多個日志文件
(
NAME =COMMONFILE,
FILENAME=,
SIZE=10,
MAXSIZE= 100,
FILEGROWTH=10
),
(
NAME =COMMONFILE_ex,
FILENAME=,
SIZE=10,
MAXSIZE= 100,
FILEGROWTH=10
)
GO
--3.0 創(chuàng)建文件組的數(shù)據(jù)庫
--創(chuàng)建主文件的文件組 ,免備案空間,虛擬主機(jī),網(wǎng)站空間,
--為了提高數(shù)據(jù)庫性能, 通常數(shù)據(jù)文件和日志文件放置在不同磁盤上。
Create database common_group
on
primary
(
NAME=group_one,
FILENAME=,
SIZE=10,
MAXSIZE=200,
FILEGROWTH=10% -- 數(shù)據(jù)庫文件的增長率
),
(NAME=group_two,
FILENAME=,
SIZE=10,
MAXSIZE=200,
FILEGROWTH=10%),
FileGroup File_Group_Common -- File_Group_Common文件組
(NAME= common_one,
FILENAME=,
SIZE=10,
MAXSIZE=100,
FILEGROWTH=5),
(NAME= common_two,
FILENAME=,
SIZE=10,
MAXSIZE=100,
FILEGROWTH=5)
--FileGroup File_Group_Common --可以存在多個文件組
--(NAME= common_one,
--FILENAME=,
--SIZE=10,
--MAXSIZE=100,
--FILEGROWTH=5),
--(NAME= common_two,
--FILENAME=,
--SIZE=10,
--MAXSIZE=100,
--FILEGROWTH=5)
LOG ON -- 多個日志文件
(
NAME =COMMONFILE,
FILENAME=,
SIZE=10,
MAXSIZE= 50,
FILEGROWTH=10
),
(
NAME =COMMONFILE_ex,
FILENAME=,
SIZE=10,
MAXSIZE= 50,
FILEGROWTH=10
)
Collate Chinese_PRC_CI_AS -- 指定的排序規(guī)則
With TRUSTWORTHY ON, DB_CHAINING ON
-- TRUSTWORTHY 可以訪問數(shù)據(jù)庫以外的數(shù)據(jù)
-- DB_CHAINING數(shù)據(jù)庫可以為跨數(shù)據(jù)庫所有權(quán)鏈的源或目標(biāo)
--filegroup_name 必須在數(shù)據(jù)庫中唯一,不能是系統(tǒng)提供的名稱 PRIMARY 和 PRIMARY_LOG。
--名稱可以是字符或 Unicode 常量,也可以是常規(guī)標(biāo)識符或分隔標(biāo)識符。 名稱必須符合標(biāo)識符規(guī)則。
--CONTAINS FILESTREAM
--指定文件組在文件系統(tǒng)中存儲 FILESTREAM 二進(jìn)制大型對象 (BLOB)。
--SIZE 和 FILEGROWTH MaxSize屬性不適用于 FILESTREAM 文件組。
--DEFAULT 指定命名文件組為數(shù)據(jù)庫中的默認(rèn)文件組。
GO
--打開的filestream 權(quán)限
EXEC sp_configure filestream_access_level, 2
RECONFIGURE
-- 這里創(chuàng)建filestream數(shù)據(jù)文件
CREATE DATABASE common_filestream
ON
PRIMARY
(NAME= common_fs,
FILENAME=,
SIZE=10,
MAXSIZE=1000,
FILEGROWTH=10),
FILEGROUP [c_filestream] CONTAINS FILESTREAM DEFAULT
(NAME =group_filestream, FILENAME=),
(NAME=group_fs, FILENAME=)
LOG ON
(NAME=log_group,
FILENAME=,
SIZE=10,
MAXSIZE=100,
FILEGROWTH= 10%
)
GO
-- 我們這里也可以在程序中直接創(chuàng)建數(shù)據(jù)庫
-- 直接使用exec執(zhí)行程序
exec ();

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

The solutions to discuz database error are: 1. Check the database configuration; 2. Make sure the database server is running; 3. Check the database table status; 4. Back up the data; 5. Clear the cache; 6. Reinstall Discuz; 7. Check the server resources ; 8. Contact Discuz official support. Solving Discuz database errors requires starting from multiple aspects, gradually identifying the cause of the problem, and taking corresponding measures to repair it.

IntelArrowLakeisexpectedtobebasedonthesameprocessorarchitectureasLunarLake,meaningthatIntel'sbrandnewLionCoveperformancecoreswillbecombinedwiththeeconomicalSkymontefficiencycores.WhileLunarLakeisonlyavailableasava

How to solve MySQL error: Unable to delete database, database does not exist Overview: MySQL is a commonly used relational database management system. When using MySQL, we often need to manage the database, including creating databases, deleting databases and other operations. However, when deleting a database, sometimes you will encounter the error message "Can'tdropdatabase'database_name';databasedoesn'texist", that is, you cannot delete it.

Using databases to store PHP session data can improve performance and scalability. 1) Configure MySQL to store session data: Set up the session processor in php.ini or PHP code. 2) Implement custom session processor: define open, close, read, write and other functions to interact with the database. 3) Optimization and best practices: Use indexing, caching, data compression and distributed storage to improve performance.

cannot. The function of the CREATE statement is to create a table structure, but it cannot append new records. You can use the INSERT statement to append new records. The CREATE statement can be used to create a new table in the database and specify the attributes and constraints of the data columns; however, the newly created table is an empty table and requires the use of the INSERT statement to append new records. The INSERT statement is used to insert one or more rows of tuple data into an existing table in the database.

Introduction Navigating through database operations in XAMPP can be challenging, particularly for beginners. Realizing this complexity, over 15 million active monthly users have turned to XAMPP for its ease of use and flexibility. This article offers

Solution to create react app error: 1. Switch the Taobao mirror source through "npm config set registry https://registry.npm.taobao.org"; 2. By executing "E:\workspace\demo\p4>npx create- react-app todolist" command to reinstall it.

InMySQL,thetermsdatabaseandschemaarenearlyinterchangeable,butcarrysubtlecontextualdifferences.2.Adatabaseisatop-levelcontainerfordataobjectsliketables,views,andprocedures,createdwithCREATEDATABASE.3.AschemainMySQLreferstoeitherthedatabaseitself—often
