From 18a0842b30c34529688b93bae5e887fddc8b4d9b Mon Sep 17 00:00:00 2001 From: Lee Date: Tue, 8 Oct 2024 10:46:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dci=EF=BC=8C=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?07?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cf.yml | 3 +- docs/sql/06/xiugai.md | 87 +++++++++++++++++++++++++++++++++++++++- docs/sql/07/1.md | 4 ++ docs/sql/07/index.md | 5 +++ 4 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 docs/sql/07/1.md create mode 100644 docs/sql/07/index.md diff --git a/.github/workflows/cf.yml b/.github/workflows/cf.yml index 7b050af..76a1e81 100644 --- a/.github/workflows/cf.yml +++ b/.github/workflows/cf.yml @@ -26,8 +26,7 @@ jobs: # 第四步:构建项目 - name: 构建项目 - run: pnpm run docs:build - + run: pnpm dev # 第五步:安装 Wrangler - name: 安装 Wrangler run: pnpm add -g wrangler@3 diff --git a/docs/sql/06/xiugai.md b/docs/sql/06/xiugai.md index cdf20b2..3c1ece4 100644 --- a/docs/sql/06/xiugai.md +++ b/docs/sql/06/xiugai.md @@ -2,6 +2,91 @@ title: 修改表 --- +## 定义 + +```sql +alter table 表名 +``` + +## 改名 + +### 更改表名 + +```sql +exec sp_rename oldname,newname +``` + +### 更改列名 + +```sql +exec sp_rename 'BiaoMing.oldname',newname +``` + +## 添加/删除 + +### 向表内添加一列Cellphone + +```sql +alter table Cuetomer +add Cellphone char(10) +``` + +### 删除Cuetomer表的Cellphone列 + +```sql +alter table Cuetomer +drop column Cellphone +``` + +## 修改列 + +### 修改列的数据类型 + ```sql +alter table 表名 +alter column 表名 数据类型 +``` -``` \ No newline at end of file +### 修改某列是否允许为空 + +```sql +alter table Cuetomer +alter column Cellphone char(11) not null +``` + +### 向Cuetomer表的CuetomerName列添加一个名为c1的唯一键约束 + +```sql +alter table Cuetomer +add constraint c1 unique(CuetomerName) +``` + +## 约束 + +### 给表加一个唯一键约束 + +```sql +alter table Cuetomer +add unique(CuetomerName) +``` + +### 向Cuetomer表的sex列添加一个名为df_sex的约束,要求默认值为they + +```sql +alter table Cuetomer +add constraint df_sex unique(sex) deflut 'they' +``` + +### 删除约束df_sex + +```sql +alter table Cuetomer +drop constraint df_sex +``` + +也可以写为 + +```sql +alter table Cuetomer +drop df_sex +``` diff --git a/docs/sql/07/1.md b/docs/sql/07/1.md new file mode 100644 index 0000000..cfc27d9 --- /dev/null +++ b/docs/sql/07/1.md @@ -0,0 +1,4 @@ +--- +title: 添加记录 +--- + diff --git a/docs/sql/07/index.md b/docs/sql/07/index.md new file mode 100644 index 0000000..a9848bc --- /dev/null +++ b/docs/sql/07/index.md @@ -0,0 +1,5 @@ +--- +title: 07.数据的输入与维护 +--- + +电脑端在左侧-侧边栏查看文档,手机端点击左上角`菜单` \ No newline at end of file