Compare commits

...

18 Commits

20 changed files with 2710 additions and 63 deletions

View File

@ -93,39 +93,92 @@ jobs:
http://localhost:9667/
```
# Create Docker Image in Github
- name: Login to GitHub registry
run: echo ${{ github.token }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build docker image
run: docker build -t ghcr.io/jaywcjlove/reference:latest .
- name: Publish to GitHub registry
run: docker push ghcr.io/jaywcjlove/reference:latest
- name: Tag docker image (beta) and publish to GitHub registry
if: steps.create_tag.outputs.successful
run: |
echo "version: v${{ steps.changelog.outputs.version }}"
docker tag ghcr.io/jaywcjlove/reference:latest ghcr.io/jaywcjlove/reference:${{steps.changelog.outputs.version}}
docker push ghcr.io/jaywcjlove/reference:${{steps.changelog.outputs.version}}
# Create Docker Image
- name: Docker login
run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }}
- name: Build reference image
run: docker image build -t reference .
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Tags & Push image(latest)
run: |
echo "DOCKER_USER: ${{ secrets.DOCKER_USER }}"
docker tag reference ${{ secrets.DOCKER_USER }}/reference:latest
docker push ${{ secrets.DOCKER_USER }}/reference:latest
- name: Build and push image:latest
uses: docker/build-push-action@v3
with:
push: true
context: .
platforms: linux/amd64,linux/arm64
tags: ${{ secrets.DOCKER_USER }}/reference:latest
- name: Tags & Push image
- name: Build and push image:tags
uses: docker/build-push-action@v3
if: steps.create_tag.outputs.successful
run: |
echo "outputs.tag - ${{ steps.changelog.outputs.version }}"
docker tag reference ${{ secrets.DOCKER_USER }}/reference:${{steps.changelog.outputs.version}}
docker push ${{ secrets.DOCKER_USER }}/reference:${{steps.changelog.outputs.version}}
with:
push: true
context: .
platforms: linux/amd64,linux/arm64
tags: ${{ secrets.DOCKER_USER }}/reference:${{steps.changelog.outputs.version}}
# Create Docker Image in Github
- name: Login to the GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push image:latest
uses: docker/build-push-action@v3
with:
push: true
context: .
platforms: linux/amd64,linux/arm64
tags: ghcr.io/jaywcjlove/reference:latest
- name: Build and push image:tags
uses: docker/build-push-action@v3
if: steps.create_tag.outputs.successful
with:
push: true
context: .
platforms: linux/amd64,linux/arm64
tags: ghcr.io/jaywcjlove/reference:${{steps.changelog.outputs.version}}
# # Create Docker Image in Github
# - name: Login to GitHub registry
# run: echo ${{ github.token }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
# - name: Build docker image
# run: docker build -t ghcr.io/jaywcjlove/reference:latest .
# - name: Publish to GitHub registry
# run: docker push ghcr.io/jaywcjlove/reference:latest
# - name: Tag docker image (beta) and publish to GitHub registry
# if: steps.create_tag.outputs.successful
# run: |
# echo "version: v${{ steps.changelog.outputs.version }}"
# docker tag ghcr.io/jaywcjlove/reference:latest ghcr.io/jaywcjlove/reference:${{steps.changelog.outputs.version}}
# docker push ghcr.io/jaywcjlove/reference:${{steps.changelog.outputs.version}}
# # Create Docker Image
# - name: Docker login
# run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }}
# - name: Build reference image
# run: docker image build -t reference .
# - name: Tags & Push image(latest)
# run: |
# echo "DOCKER_USER: ${{ secrets.DOCKER_USER }}"
# docker tag reference ${{ secrets.DOCKER_USER }}/reference:latest
# docker push ${{ secrets.DOCKER_USER }}/reference:latest
# - name: Tags & Push image
# if: steps.create_tag.outputs.successful
# run: |
# echo "outputs.tag - ${{ steps.changelog.outputs.version }}"
# docker tag reference ${{ secrets.DOCKER_USER }}/reference:${{steps.changelog.outputs.version}}
# docker push ${{ secrets.DOCKER_USER }}/reference:${{steps.changelog.outputs.version}}

View File

@ -80,13 +80,66 @@ Contributing 贡献
## 本地开发
```bash
npm i # 安装依赖
npm run build # 编译输出 HTML
npm run start # 监听 md 文件编译输出 HTML
$ git clone https://github.com/jaywcjlove/reference.git
$ npm i # 安装依赖
$ npm run build # 编译输出 HTML
$ npm run start # 监听 md 文件编译输出 HTML
```
或者你也可以使用 `pnpm` 或者 `yarn` 做为包管理器
## 快捷部署方法
由于中国国内访问,时常打不开,推荐您部署的镜像网站,大家可以在这里留言推荐您的镜像网站网址,我将放置在首页推荐
### 方法一,只需要克隆 gh-pages 分支代码到你的静态服务就可以了
```shell
$ git clone https://github.com/jaywcjlove/reference.git -b gh-pages
```
### 方法二,使用 [docker](https://hub.docker.com/r/wcjiang/reference) 快捷部署 web 版
```shell
$ docker pull wcjiang/reference
$ docker run --name reference --rm -d -p 9667:3000 wcjiang/reference:latest
# Or
$ docker run --name reference -itd -p 9667:3000 wcjiang/reference:latest
```
### 方法三,克隆仓库自己编译,添加导航菜单
```bash
$ git clone https://github.com/jaywcjlove/reference.git
$ npm install # 安装依赖
$ npm run build # 编译输出静态页面
$ npm run start # 开发模式,监听实时编译输出静态页面
```
文件被输出到 `dist` 目录,将 `dist` 目录静态页面部署到静态服务就可以了
<img width="423" alt="image" src="https://user-images.githubusercontent.com/1680273/203210099-cd9e1377-bceb-40cc-98f1-4c4c549a3986.png">
提供自定义菜单,在项目的根目录建立 `.env` 文件,添加下面内容
```ini
REF_URL=http://ref.xxx.cn/
REF_LABEL=网站首页
```
### 国内镜像
由于中国国内访问,时常打不开,你可以访问下面镜像网站。
- [ecdata.cn](http://ref.ecdata.cn)
- [mofe.io](http://quickref.mofe.io)
- [aibk.cn](https://quickref.aibk.cn)
- [laoleng.vip](http://bbs.laoleng.vip/reference/)
- [liujiapeng.com](https://www.liujiapeng.com/)
- [dbyun.net](https://www.dbyun.net/reference/index.html)
感谢🙏
## 贡献

View File

@ -29,8 +29,9 @@ Quick Reference
[Lua](./docs/lua.md)<!--rehype:style=background: rgb(3 3 128);-->
[NestJS](./docs/nestjs.md)<!--rehype:style=background: rgb(237 21 67);&class=contributing-->
[MATLAB](./docs/matlab.md)<!--rehype:style=background: rgb(0 118 168);&class=contributing-->
[Vue 3](./docs/vue.md)<!--rehype:style=background: rgb(64 184 131);&class=contributing-->
[Oracle](./docs/oracle.md)<!--rehype:style=background: rgb(255 0 0);&class=contributing tag&data-lang=SQL-->
[Pytorch](./docs/pytorch.md)<!--rehype:style=background: rgb(238 76 44);&class=contributing tag&data-lang=Python&data-info=👆看看还缺点儿什么?-->
[Vue 3](./docs/vue.md)<!--rehype:style=background: rgb(64 184 131);&class=contributing-->
<!--rehype:class=home-card-->
## 编程
@ -52,9 +53,11 @@ Quick Reference
[Julia](./docs/julia.md)<!--rehype:style=background: rgb(211 55 49);&class=contributing&data-info=👆看看还缺点儿什么?-->
[Kotlin](./docs/kotlin.md)<!--rehype:style=background: rgb(211 55 49);&class=contributing&data-info=👆看看还缺点儿什么?-->
[LaTeX](./docs/latex.md)<!--rehype:style=background: rgb(0 128 128);&class=contributing-->
[Laravel 8](./docs/laravel.md)<!--rehype:style=background: rgb(249 50 44);&class=contributing tag&data-lang=PHP-->
[Markdown](./docs/markdown.md)<!--rehype:style=background: rgb(103 61 156);-->
[MySQL](./docs/mysql.md)<!--rehype:style=background: rgb(1 117 143);&class=tag&data-lang=SQL-->
[MATLAB](./docs/matlab.md)<!--rehype:style=background: rgb(0 118 168);&class=contributing-->
[Oracle](./docs/oracle.md)<!--rehype:style=background: rgb(255 0 0);-->
[PHP](./docs/php.md)<!--rehype:style=background: rgb(79 91 147);-->
[Python](./docs/python.md)<!--rehype:style=background: rgb(43 91 132);-->
[PostgreSQL](./docs/postgres.md)<!--rehype:style=background: rgb(43 109 163);&class=tag&data-lang=SQL-->
@ -74,7 +77,7 @@ Quick Reference
[Electron](./docs/electron.md)<!--rehype:style=background: rgb(0 72 153);-->
[Emmet](./docs/emmet.md)<!--rehype:style=background: rgb(122 203 23);-->
[ES 6](./docs/es6.md)<!--rehype:style=background: rgb(122 203 23);&class=tag&data-lang=JS-->
[Styled Components](./docs/styled-components.md)<!--rehype:style=background: rgb(221 60 184);-->
[Styled Components](./docs/styled-components.md)<!--rehype:style=background: rgb(221 60 184);&class=tag&data-lang=CSS-->
[Stylus](./docs/stylus.md)<!--rehype:style=background: rgb(109 161 63);&class=tag&data-lang=CSS-->
[Sass](./docs/sass.md)<!--rehype:style=background: rgb(207 100 154);&class=tag&data-lang=CSS-->
[HTML](./docs/html.md)<!--rehype:style=background: rgb(228 77 39);-->
@ -316,11 +319,16 @@ Quick Reference
## 国内镜像网站
<!--rehype:wrap-style=text-align: center;max-width: 650px;margin: 0 auto;&class=home-title-reset-->
由于中国国内访问,时常打不开,你可以访问下面镜像网站。推荐的[镜像网站](https://github.com/jaywcjlove/reference/issues/102#issue-1451649637)
由于中国国内访问,时常打不开,你可以访问下面镜像网站。推荐自己的[镜像网站](https://github.com/jaywcjlove/reference/issues/102#issue-1451649637)
[ecdata.cn](http://ref.ecdata.cn/)<!--rehype:style=background: rgb(16 185 129);height: 3rem;-->
[mofe.io](http://quickref.mofe.io)<!--rehype:style=background: rgb(16 185 129);height: 3rem;-->
<!--rehype:class=home-card&style=margin:1.2rem 0;display: flex;justify-content: center;-->
[ecdata.cn](http://ref.ecdata.cn)<!--rehype:target=_blank&style=background: rgb(16 185 129);height: 2.6rem;border-radius: 2rem;font-weight: bold;-->
[mofe.io](http://quickref.mofe.io)<!--rehype:target=_blank&style=background: rgb(16 185 129);height: 2.6rem;border-radius: 2rem;font-weight: bold;-->
[aibk.cn](https://quickref.aibk.cn)<!--rehype:target=_blank&style=background: rgb(16 185 129);height: 2.6rem;border-radius: 2rem;font-weight: bold;-->
[laoleng.vip](http://bbs.laoleng.vip/reference/)<!--rehype:target=_blank&style=background: rgb(16 185 129);height: 2.6rem;border-radius: 2rem;font-weight: bold;-->
[liujiapeng.com](https://www.liujiapeng.com/)<!--rehype:target=_blank&style=background: rgb(16 185 129);height: 2.6rem;border-radius: 2rem;font-weight: bold;-->
[dbyun.net](https://www.dbyun.net/reference/index.html)<!--rehype:target=_blank&style=background: rgb(16 185 129);height: 2.6rem;border-radius: 2rem;font-weight: bold;-->
[cyolc932.fun](https://cyolc932.fun/reference/)<!--rehype:target=_blank&style=background: rgb(16 185 129);height: 2.6rem;border-radius: 2rem;font-weight: bold;&class=contributing tag&data-info=👆需要梯子-->
<!--rehype:class=home-card&style=margin:2.2rem 0;display: flex;justify-content: center;gap: 1rem;flex-wrap: wrap;-->
如果你有资源,可以很方便部署 web 版,这非常简单,只需要克隆 gh-pages 分支代码到你的静态服务就可以了,还可以使用 [docker](https://hub.docker.com/r/wcjiang/reference) 快捷部署 web 版。

View File

@ -36,7 +36,7 @@ double doubleNum = 99.999;
decimal decimalNum = 99.9999M;
char letter = 'D';
bool @bool = true;
string site = "quickref.me";
string site = "jaywcjlove.github.io";
var num = 999;
var str = "999";
var bo = false;

View File

@ -855,7 +855,7 @@ meta 标记描述 HTML 文档中的元数据。它解释了关于 HTML 的其他
<meta property="og:type" content="website">
<meta property="og:locale" content="en_CA">
<meta property="og:title" content="HTML cheatsheet">
<meta property="og:url" content="https://quickref.me/html">
<meta property="og:url" content="https://jaywcjlove.github.io/">
<meta property="og:image" content="https://xxx.com/image.jpg">
<meta property="og:site_name" content="Name of your website">
<meta property="og:description" content="Description of this page">
@ -869,7 +869,7 @@ Facebook、Instagram、Pinterest、LinkedIn 等使用。
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="@QuickRef_ME">
<meta name="twitter:title" content="HTML cheatsheet">
<meta name="twitter:url" content="https://quickref.me/html">
<meta name="twitter:url" content="https://jaywcjlove.github.io/">
<meta name="twitter:description" content="Description of this page">
<meta name="twitter:image" content="https://xxx.com/image.jpg">
```

View File

@ -35,7 +35,7 @@ int num = 5;
float floatNum = 5.99f;
char letter = 'D';
boolean bool = true;
String site = "quickref.me";
String site = "jaywcjlove.github.io";
```
### 原始数据类型

View File

@ -64,8 +64,8 @@ JSON 备忘清单
```json
{
"url": "https://quickref.me",
"msg" : "Hi,\n\"QuickRef.ME\"",
"url": "https://jaywcjlove.github.io",
"msg" : "Hi,\n\"Quick Reference\"",
"intro": "Share quick reference and cheat sheet for developers."
}
```

1838
docs/laravel.md Normal file

File diff suppressed because it is too large Load Diff

647
docs/oracle.md Normal file
View File

@ -0,0 +1,647 @@
Oracle 备忘清单
===
入门
---
<!--rehype:body-class=cols-2-->
### SELECT 语句
```sql
SELECT * FROM beverages WHERE field1 = 'Kona' AND field2 = 'coffee' AND field3 = 122;
```
<!--rehype:className=wrap-text-->
### SELECT INTO 语句
```sql
SELECT name,address,phone_number INTO v_employee_name,v_employee_address,v_employee_phone_number FROM employee WHERE employee_id = 6;
```
<!--rehype:className=wrap-text-->
### INSERT 语句
<!--rehype:wrap-class=row-span-2-->
使用 VALUES 关键字插入
```sql
INSERT INTO table_name VALUES ('Value1', 'Value2', ... );
INSERT INTO table_name(Column1, Column2, ... ) VALUES ( 'Value1', 'Value2', ... );
```
<!--rehype:className=wrap-text-->
使用 SELECT 语句插入
```sql
INSERT INTO table_name(SELECT Value1, Value2, ... from table_name );
INSERT INTO table_name(Column1, Column2, ... ) ( SELECT Value1, Value2, ... from table_name );
```
<!--rehype:className=wrap-text-->
### DELETE 语句
```sql
DELETE FROM table_name WHERE some_column=some_value
DELETE FROM customer WHERE sold = 0;
```
### UPDATE 语句
```sql
-- 更新该表的整个列,设置 `state` 列所有值为 `CA`
UPDATE customer SET state='CA';
-- 更新表的具体记录eg
UPDATE customer SET name='Joe' WHERE customer_id=10;
-- 当 `paid` 列大于零时,将列 `invoice` 更新为 `paid`
UPDATE movies SET invoice='paid' WHERE paid > 0;
```
SEQUENCES
---
### CREATE SEQUENCE
序列的语法是
```sql
CREATE SEQUENCE sequence_name
MINVALUE value
MAXVALUE value
START WITH value
INCREMENT BY value
CACHE value;
```
例如
```sql
CREATE SEQUENCE supplier_seq
MINVALUE 1
MAXVALUE 999999999999999999999999999
START WITH 1
INCREMENT BY 1
CACHE 20;
```
### ALTER SEQUENCE
<!--rehype:wrap-class=col-span-2-->
将序列增加一定数量
```sql
ALTER SEQUENCE <sequence_name> INCREMENT BY <integer>;
ALTER SEQUENCE seq_inc_by_ten INCREMENT BY 10;
```
改变序列的最大值
```sql
ALTER SEQUENCE <sequence_name> MAXVALUE <integer>;
ALTER SEQUENCE seq_maxval MAXVALUE 10;
```
设置序列循环或不循环
```sql
ALTER SEQUENCE <sequence_name> <CYCLE | NOCYCLE>;
ALTER SEQUENCE seq_cycle NOCYCLE;
```
配置序列以缓存值
```sql
ALTER SEQUENCE <sequence_name> CACHE <integer> | NOCACHE;
ALTER SEQUENCE seq_cache NOCACHE;
```
设置是否按顺序返回值
```sql
ALTER SEQUENCE <sequence_name> <ORDER | NOORDER>;
ALTER SEQUENCE seq_order NOORDER;
ALTER SEQUENCE seq_order;
```
### 从字符串生成查询
<!--rehype:wrap-class=row-span-2-->
有时需要从字符串创建查询
```sql
PROCEDURE oracle_runtime_query_pcd IS
TYPE ref_cursor IS REF CURSOR;
l_cursor ref_cursor;
v_query varchar2(5000);
v_name varchar2(64);
BEGIN
v_query := 'SELECT name FROM employee WHERE employee_id=5';
OPEN l_cursor FOR v_query;
LOOP
FETCH l_cursor INTO v_name;
EXIT WHEN l_cursor%NOTFOUND;
END LOOP;
CLOSE l_cursor;
END;
```
<!--rehype:className=wrap-text-->
这是一个如何完成动态查询的非常简单的示例
### 字符串操作
```sql
length( string1 );
```
---
```sql
SELECT length('hello world') FROM dual;
```
这将返回 11因为参数由 11 个字符组成,包括空格
```sql
SELECT lengthb('hello world') FROM dual;
SELECT lengthc('hello world') FROM dual;
SELECT length2('hello world') FROM dual;
SELECT length4('hello world') FROM dual;
```
这些也返回 `11`,因为调用的函数是等价的
### Instr
<!--rehype:wrap-class=row-span-2-->
`Instr`(在字符串中)返回一个整数,该整数指定字符串中子字符串的位置。程序员可以指定他们想要检测的字符串的外观以及起始位置。不成功的搜索返回 `0`
```sql
instr( string1, string2, [ start_position ], [ nth_appearance ] )
```
<!--rehype:className=wrap-text-->
---
```sql
instr( 'oracle pl/sql cheatsheet', '/');
```
这将返回 `10`,因为第一次出现的 `/` 是第十个字符
```sql
instr( 'oracle pl/sql cheatsheet', 'e', 1, 2);
```
<!--rehype:className=wrap-text-->
这将返回 `17`,因为第二次出现的 `e` 是第 `17` 个字符
```sql
instr( 'oracle pl/sql cheatsheet', '/', 12, 1);
```
<!--rehype:className=wrap-text-->
这将返回 `0`,因为第一次出现的 `/` 在起点之前,即第 `12` 个字符
### Replace
```sql
replace(string1, string_to_replace, [ replacement_string ] );
replace('i am here','am','am not');
```
<!--rehype:className=wrap-text-->
这返回 `i am not here`
### Substr
```sql
SELECT substr( 'oracle pl/sql cheatsheet', 8, 6) FROM dual;
```
<!--rehype:className=wrap-text-->
返回 `pl/sql`,因为 `pl/sql` 中的 `p` 在字符串中的第 `8` 个位置(从 `oracle` 中的 `o` 处的 `1` 开始计算)
```sql
SELECT substr( 'oracle pl/sql cheatsheet', 15) FROM dual;
```
<!--rehype:className=wrap-text-->
返回 `cheatsheet`,因为 `c` 在字符串中的第 `15` 个位置,`t`是字符串中的最后一个字符。
```sql
SELECT substr('oracle pl/sql cheatsheet', -10, 5) FROM dual;
```
<!--rehype:className=wrap-text-->
返回 `cheat`,因为 `c` 是字符串中的第 `10` 个字符,从字符串末尾以 `t` 作为位置 `1` 开始计算。
### Trim
这些函数可用于从字符串中过滤不需要的字符。默认情况下,它们会删除空格,但也可以指定要删除的字符集
```sql
trim ( [ leading | trailing | both ] [ trim-char ] from string-to-be-trimmed );
trim (' 删除两侧的空格 ');
```
<!--rehype:className=wrap-text-->
这将返回“`删除两侧的空格`
```sql
ltrim ( string-to-be-trimmed [, trimming-char-set ] );
ltrim (' 删除左侧的空格 ');
```
<!--rehype:className=wrap-text-->
这将返回“`删除左侧的空格`&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
```sql
rtrim ( string-to-be-trimmed [, trimming-char-set ] );
rtrim (' 删除右侧的空格 ');
```
<!--rehype:className=wrap-text-->
这将返回“&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`删除右侧的空格`
DDL SQL
---
### 创建表
创建表的语法
```sql
CREATE TABLE [table name]
( [column name] [datatype], ... );
```
示例:
```sql
CREATE TABLE employee
(id int, name varchar(20));
```
### 添加列
添加列的语法
```sql
ALTER TABLE [table name]
ADD ( [column name] [datatype], ... );
```
示例:
```sql
ALTER TABLE employee
ADD (id int)
```
### 修改列
修改列的语法
```sql
ALTER TABLE [table name]
MODIFY ( [column name] [new datatype]);
```
`ALTER` 表语法和示例:
```sql
ALTER TABLE employee
MODIFY( sickHours s float );
```
### 删除列
删除列的语法
```sql
ALTER TABLE [table name]
DROP COLUMN [column name];
```
示例:
```sql
ALTER TABLE employee
DROP COLUMN vacationPay;
```
### 约束类型和代码
类型代码 | 类型描述 | 作用于级别
:-- | -- | --
`C` | 检查表 | Column
`O` | 在视图上只读 | Object
`P` | 首要的关键 | Object
`R` | 参考 AKA 外键 | Column
`U` | 唯一键 | Column
`V` | 检查视图上的选项 | Object
### 显示约束
以下语句显示了系统中的所有约束:
```sql
SELECT
table_name,
constraint_name,
constraint_type
FROM user_constraints;
```
### 选择参照约束
以下语句显示了源和目标表/列对的所有引用约束(外键):
```sql
SELECT
c_list.CONSTRAINT_NAME as NAME,
c_src.TABLE_NAME as SRC_TABLE,
c_src.COLUMN_NAME as SRC_COLUMN,
c_dest.TABLE_NAME as DEST_TABLE,
c_dest.COLUMN_NAME as DEST_COLUMN
FROM ALL_CONSTRAINTS c_list,
ALL_CONS_COLUMNS c_src,
ALL_CONS_COLUMNS c_dest
WHERE c_list.CONSTRAINT_NAME = c_src.CONSTRAINT_NAME
AND c_list.R_CONSTRAINT_NAME = c_dest.CONSTRAINT_NAME
AND c_list.CONSTRAINT_TYPE = 'R'
```
### 对表设置约束
使用 `CREATE TABLE` 语句创建检查约束的语法是:
```sql
CREATE TABLE table_name
(
column1 datatype null/not null,
column2 datatype null/not null,
...
CONSTRAINT constraint_name CHECK (column_name condition) [DISABLE]
);
```
例如:
```sql
CREATE TABLE suppliers
(
supplier_id numeric(4),
supplier_name varchar2(50),
CONSTRAINT check_supplier_id
CHECK (supplier_id BETWEEN 100 and 9999)
);
```
### 表上的唯一索引
使用 `CREATE TABLE` 语句创建唯一约束的语法是:
```sql
CREATE TABLE table_name
(
column1 datatype null/not null,
column2 datatype null/not null,
...
CONSTRAINT constraint_name UNIQUE (column1, column2, column_n)
);
```
例如:
```sql
CREATE TABLE customer
(
id integer not null,
name varchar2(20),
CONSTRAINT customer_id_constraint UNIQUE (id)
);
```
### 添加唯一约束
唯一约束的语法是:
```sql
ALTER TABLE [table name]
ADD CONSTRAINT [constraint name] UNIQUE( [column name] ) USING INDEX [index name];
```
例如:
```sql
ALTER TABLE employee
ADD CONSTRAINT uniqueEmployeeId UNIQUE(employeeId) USING INDEX ourcompanyIndx_tbs;
```
### 添加外部约束
foregin 约束的语法是:
```sql
ALTER TABLE [table name]
ADD CONSTRAINT [constraint name] FOREIGN KEY (column,...) REFERENCES table [(column,...)] [ON DELETE {CASCADE | SET NULL}]
```
例如:
```sql
ALTER TABLE employee
ADD CONSTRAINT fk_departament FOREIGN KEY (departmentId) REFERENCES departments(Id);
```
### 删除约束
删除(删除)约束的语法是:
```sql
ALTER TABLE [table name]
DROP CONSTRAINT [constraint name];
```
例如:
```sql
ALTER TABLE employee
DROP CONSTRAINT uniqueEmployeeId;
```
INDEXES
----
### 创建索引
创建索引的语法是:
```sql
CREATE [UNIQUE] INDEX index_name
ON table_name (column1, column2, . column_n)
[ COMPUTE STATISTICS ];
```
`UNIQUE` 表示索引列中值的组合必须是唯一的
`COMPUTE STATISTICS` 告诉 Oracle 在创建索引期间收集统计信息。 然后优化器使用这些统计信息来选择执行语句时的最佳执行计划。例如:
```sql
CREATE INDEX customer_idx
ON customer (customer_name);
```
在此示例中,已在名为 `customer_idx` 的客户表上创建了一个索引。它仅包含 `customer_name` 字段
下面创建一个包含多个字段的索引:
```sql
CREATE INDEX customer_idx
ON supplier (customer_name, country);
```
以下内容在创建索引时收集统计信息:
```sql
CREATE INDEX customer_idx
ON supplier (customer_name, country)
COMPUTE STATISTICS;
```
### 创建基于函数的索引
<!--rehype:wrap-class=col-span-2-->
`Oracle` 中,您不仅限于在列上创建索引。您可以创建基于函数的索引
创建基于函数的索引的语法是:
```sql
CREATE [UNIQUE] INDEX index_name
ON table_name (function1, function2, . function_n)
[ COMPUTE STATISTICS ];
```
例如:
```sql
CREATE INDEX customer_idx
ON customer (UPPER(customer_name));
-- 已创建基于 customer_name 字段的大写评估的索引
```
为确保 `Oracle` 优化器在执行 SQL 语句时使用此索引,请确保 `UPPER(customer_name)` 的计算结果不为 `NULL` 值。 为确保这一点,请将 `UPPER(customer_name) IS NOT NULL` 添加到 `WHERE` 子句中,如下所示:
```sql
SELECT customer_id, customer_name, UPPER(customer_name)
FROM customer
WHERE UPPER(customer_name) IS NOT NULL
ORDER BY UPPER(customer_name);
```
### 重命名索引
重命名索引的语法是:
```sql
ALTER INDEX index_name
RENAME TO new_index_name;
```
例如:
```sql
ALTER INDEX customer_id
RENAME TO new_customer_id;
```
在此示例中,`customer_id` 重命名为 `new_customer_id`
### 收集索引的统计信息
如果您需要在索引首次创建后收集统计信息或者您想要更新统计信息,您总是可以使用 ALTER INDEX 命令来收集统计信息。 您收集统计信息以便 `oracle` 可以有效地使用索引。 这将重新计算表大小、行数、块数、段数并更新字典表,以便 `oracle` 在选择执行计划时可以有效地使用数据。
收集索引统计信息的语法是:
```sql
ALTER INDEX index_name
REBUILD COMPUTE STATISTICS;
```
例如:
```sql
ALTER INDEX customer_idx
REBUILD COMPUTE STATISTICS;
```
在此示例中,为名为 `customer_idx` 的索引收集统计信息
### 删除索引
删除索引的语法是:
```sql
DROP INDEX index_name;
```
例如:
```sql
DROP INDEX customer_idx;
```
在此示例中,删除了 `customer_idx`
DBA 相关
---
### 创建用户
创建用户的语法是:
```sql
CREATE USER username IDENTIFIED BY password;
```
例如:
```sql
CREATE USER brian IDENTIFIED BY brianpass;
```
### 授予特权
授予权限的语法是:
```sql
GRANT privilege TO user;
```
例如:
```sql
GRANT dba TO brian;
```
### 更改密码
更改用户密码的语法是:
```sql
ALTER USER username IDENTIFIED BY password;
```
例如:
```sql
ALTER USER brian IDENTIFIED BY brianpassword;
```
另见
---
- [Oracle Database/SQL Cheatsheet](https://en.wikibooks.org/wiki/Oracle_Database/SQL_Cheatsheet) _(wikibooks.org)_

View File

@ -11,7 +11,7 @@ PHP 备忘清单
```php
<?php // 以 PHP 开放标签开头
echo "Hello World\n";
print("Hello quickref.me");
print("Hello jaywcjlove.github.io");
?>
```
@ -38,7 +38,7 @@ $str2 = 'Fine, thanks';
### 字符串 Strings
```php
$url = "quickref.me";
$url = "jaywcjlove.github.io";
echo "I'm learning PHP at $url";
// 连接字符串
echo "I'm learning PHP at " . $url;
@ -938,7 +938,7 @@ if (is_null($repo)) {
### 常用表达
```php
$str = "Visit Quickref.me";
$str = "Visit jaywcjlove.github.io";
echo preg_match("/qu/i", $str); # => 1
```

View File

@ -10,7 +10,7 @@ Python 备忘单是 [Python 3](https://www.python.org/) 编程语言的单页参
- [Python](https://www.python.org/) _(python.org)_
- [Learn X in Y minutes](https://learnxinyminutes.com/docs/python/) _(learnxinyminutes.com)_
- [Regex in python](./regex.md#python-中的正则表达式) _(quickref.me)_
- [Regex in python](./regex.md#python-中的正则表达式) _(jaywcjlove.github.io)_
### Hello World
@ -144,9 +144,9 @@ message += "Part 2."
### f-字符串(Python 3.6+)
```python
>>> website = 'Quickref.ME'
>>> website = 'Quick Reference'
>>> f"Hello, {website}"
"Hello, Quickref.ME"
"Hello, Quick Reference"
>>> num = 10
>>> f'{num} + 10 = {num + 10}'
'10 + 10 = 20'
@ -1238,4 +1238,4 @@ finally: # 在所有情况下执行
- [Python](https://www.python.org/) _(python.org)_
- [Learn X in Y minutes](https://learnxinyminutes.com/docs/python/) _(learnxinyminutes.com)_
- [Regex in python](./regex.md#python-中的正则表达式) _(quickref.me)_
- [Regex in python](./regex.md#python-中的正则表达式) _(jaywcjlove.github.io)_

View File

@ -1,4 +1,4 @@
styled-components 备忘清单
Styled Components 备忘清单
====
此快速参考备忘单提供了使用 CSS in JS 工具的各种方法。

View File

@ -1,6 +1,6 @@
{
"name": "@wcj/reference",
"version": "1.25.0",
"version": "1.26.0",
"description": "为开发人员分享快速参考备忘单(主要是方便自己)。",
"author": "jaywcjlove",
"license": "MIT",
@ -25,6 +25,7 @@
"@uiw/formatter": "^1.3.3",
"@wcj/markdown-to-html": "^2.2.0",
"chokidar": "^3.5.3",
"dotenv": "^16.0.3",
"fs-extra": "^10.1.0",
"husky": "^8.0.1",
"lint-staged": "^13.0.3",

View File

@ -0,0 +1,3 @@
<svg viewBox="0 0 256 264" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid" height="1em" width="1em">
<path d="M255.856 59.62c.095.351.144.713.144 1.077v56.568c0 1.478-.79 2.843-2.073 3.578L206.45 148.18v54.18a4.135 4.135 0 0 1-2.062 3.579l-99.108 57.053c-.227.128-.474.21-.722.299-.093.03-.18.087-.278.113a4.15 4.15 0 0 1-2.114 0c-.114-.03-.217-.093-.325-.134-.227-.083-.464-.155-.68-.278L2.073 205.938A4.128 4.128 0 0 1 0 202.36V32.656c0-.372.052-.733.144-1.083.031-.119.103-.227.145-.346.077-.216.15-.438.263-.639.077-.134.19-.242.283-.366.119-.165.227-.335.366-.48.119-.118.274-.206.408-.309.15-.124.283-.258.453-.356h.005L51.613.551a4.135 4.135 0 0 1 4.125 0l49.546 28.526h.01c.165.104.305.232.454.351.134.103.284.196.402.31.145.149.248.32.371.484.088.124.207.232.279.366.118.206.185.423.268.64.041.118.113.226.144.35.095.351.144.714.145 1.078V138.65l41.286-23.773V60.692c0-.36.052-.727.145-1.072.036-.124.103-.232.144-.35.083-.217.155-.44.268-.64.077-.134.19-.242.279-.366.123-.165.226-.335.37-.48.12-.118.269-.206.403-.309.155-.124.289-.258.454-.356h.005l49.551-28.526a4.13 4.13 0 0 1 4.125 0l49.546 28.526c.175.103.309.232.464.35.128.104.278.197.397.31.144.15.247.32.37.485.094.124.207.232.28.366.118.2.185.423.267.64.047.118.114.226.145.35Zm-8.115 55.258v-47.04l-17.339 9.981-23.953 13.792v47.04l41.297-23.773h-.005Zm-49.546 85.095V152.9l-23.562 13.457-67.281 38.4v47.514l90.843-52.3ZM8.259 39.796v160.177l90.833 52.294v-47.505L51.64 177.906l-.015-.01-.02-.01c-.16-.093-.295-.227-.444-.34-.13-.104-.279-.186-.392-.3l-.01-.015c-.134-.129-.227-.289-.34-.433-.104-.14-.227-.258-.31-.402l-.005-.016c-.093-.154-.15-.34-.217-.515-.067-.155-.154-.3-.196-.464v-.005c-.051-.196-.061-.403-.082-.604-.02-.154-.062-.309-.062-.464V63.57L25.598 49.772l-17.339-9.97v-.006ZM53.681 8.893 12.399 32.656l41.272 23.762L94.947 32.65 53.671 8.893h.01Zm21.468 148.298 23.948-13.786V39.796L81.76 49.778 57.805 63.569v103.608l17.344-9.986ZM202.324 36.935l-41.276 23.762 41.276 23.763 41.271-23.768-41.27-23.757Zm-4.13 54.676-23.953-13.792-17.338-9.981v47.04l23.948 13.787 17.344 9.986v-47.04Zm-94.977 106.006 60.543-34.564 30.264-17.272-41.246-23.747-47.489 27.34-43.282 24.918 41.21 23.325Z" fill="currentColor"/>
</svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" height="1em" width="1em">
<path fill="currentColor" fill-rule="evenodd" d="M7.957 18.912A6.953 6.953 0 0 1 1 11.962 6.963 6.963 0 0 1 7.957 5h8.087A6.961 6.961 0 0 1 23 11.962a6.952 6.952 0 0 1-6.956 6.95H7.957Zm7.907-2.453a4.497 4.497 0 0 0 4.503-4.497 4.507 4.507 0 0 0-4.503-4.508H8.136a4.507 4.507 0 0 0-4.503 4.508 4.498 4.498 0 0 0 4.503 4.497h7.728Z"/>
</svg>

After

Width:  |  Height:  |  Size: 429 B

View File

@ -25,6 +25,7 @@ export function create(str = '', options = {}) {
description = (description[0] || '')
.replace(/^\n[=\n]+/, '')
.replace(/\[([\s\S]*?)?\]\(([\s\S]*?)?\)/g, '$1')
.replace(/<!--([\s\S]*?)-->/gi, '')
.replace(/\n/, '');
const subTitle = options.filename && !options.isHome ? `${options.filename} cheatsheet & ` : '';
/** 用于搜索数据 */

View File

@ -78,7 +78,8 @@ document.addEventListener('keydown', (ev) => {
searchBox.classList.contains('show') ? hideSearch() : showSearch();
}
if (ev.key.toLocaleLowerCase() === 'enter') {
window.location.href = getDocUrl(activeMenu.path)
const url = activeMenu.path || activeMenu?.item.path;
window.location.href = getDocUrl(url);
}
if (ev.key.toLocaleLowerCase() === 'arrowdown') {
activeAnchorElm('down')
@ -131,7 +132,7 @@ function searchResult(value) {
}
let menuHTML = '';
result.forEach((item, idx) => {
const label = item.item.name.replace(getValueReg(value), (txt) => {
const label = (item.item.name || '').replace(getValueReg(value), (txt) => {
return `<mark>${txt}</mark>`;
})
const tags = (item.item.tags || []).join(',').replace(getValueReg(value), (txt) => {

View File

@ -1,11 +1,29 @@
import path from 'path';
import { github, editor } from './logo.mjs';
import * as dotenv from 'dotenv';
import { github, editor, home } from './logo.mjs';
import { getSVGNode } from '../utils/getSVGNode.mjs';
import { darkMode } from '../utils/darkMode.mjs';
dotenv.config();
const ICONS_PATH = path.resolve(process.cwd(), 'scripts/assets/quickreference.svg');
const ICONS_SEARCH_PATH = path.resolve(process.cwd(), 'scripts/assets/search.svg');
export function getReferrals() {
const url = process.env.REF_URL;
const label = process.env.REF_LABEL;
if (!url || !label) return [];
return [
{
menu: true,
href: url,
target: '__blank',
label: label,
children: [home],
},
];
}
export function header({ homePath, githubURL = '', isHome } = {}) {
const svgNode = getSVGNode(ICONS_PATH);
const svgSearchNode = getSVGNode(ICONS_SEARCH_PATH);
@ -43,6 +61,7 @@ export function header({ homePath, githubURL = '', isHome } = {}) {
},
],
},
...getReferrals(),
{
menu: true,
href: githubURL,

View File

@ -94,3 +94,23 @@ export const editor = {
},
],
};
export const home = {
type: 'element',
tagName: 'svg',
properties: {
viewBox: '0 0 24 24',
fill: 'currentColor',
height: '1em',
width: '1em',
},
children: [
{
type: 'element',
tagName: 'path',
properties: {
d: 'M12.74 2.32a1 1 0 0 0-1.48 0l-9 10A1 1 0 0 0 3 14h2v7a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-7h2a1 1 0 0 0 1-1 1 1 0 0 0-.26-.68z',
},
},
],
};

View File

@ -527,10 +527,10 @@ a.text-grey {
.header-nav .menu a,
.header-nav .menu button {
padding-left: 0.75rem;
padding-right: 0.75rem;
padding-top: 0.5rem;
padding-bottom: 0.5rem;
padding-left: 0.55rem;
padding-right: 0.55rem;
padding-top: 0.4rem;
padding-bottom: 0.4rem;
border-radius: 9999px;
transition: all 0.3s;
border: 0;