#130 华人与华侨
个人 2016-03-16每次春晚都必然问候海外华人华侨,但我从来没有思考过华人和华侨有什么区别,近日看到网络上的一些资料才弄明白。
coding in a complicated world
每次春晚都必然问候海外华人华侨,但我从来没有思考过华人和华侨有什么区别,近日看到网络上的一些资料才弄明白。
# 时间清零
touch -amt 197001010000.00 <file>
sudo apt install -y xattr
xattr -l <file>
# 删除所有附加属性
xattr -c <file>
ess-cue-el
, 但至今为止,不少人还是将其读做 /ˈsiːkwəl/
。SQL-86 (or SQL-87) is the ISO 9075:1987 standard of 1987
SQL-89 is the ISO/IEC 9075:1989 standard of 1989
SQL-92 is the ISO/IEC 9075:1992 standard of 1992
SQL:1999 is the ISO/IEC 9075:1999 standard of 1999
SQL:2003 is the ISO/IEC 9075:2003 standard of 2003
SQL:2006 is the ISO/IEC 9075:2006 standard of 2006
SQL:2008 is the ISO/IEC 9075:2008 standard of 2008
SQL:2011 is the ISO/IEC 9075:2011 standard of 2011
SQL:2016 is the ISO/IEC 9075:2016 standard of 2016
Year | Name | Alias | Comments |
---|---|---|---|
1986 | SQL-86 | SQL-87 | First formalized by ANSI |
1989 | SQL-89 | Minor revision that added integrity constraints | |
1992 | SQL-92 | SQL2 | Major revision (ISO 9075) |
1999 | SQL:1999 | SQL3 | |
2003 | SQL:2003 | ||
2006 | SQL:2006 | ||
2008 | SQL:2008 | ||
2011 | SQL:2011 | ||
2016 | SQL:2016 | ||
2019 | SQL:2019 |
SQL:1999
Added regular expression matching, recursive queries (e.g. transitive closure), triggers, support for procedural and control-of-flow statements, nonscalar types (arrays), and some object-oriented features (e.g. structured types), support for embedding SQL in Java (SQL/OLB) and vice versa (SQL/JRT)
2003
Introduced XML-related features (SQL/XML), window functions, standardized sequences, and columns with autogenerated values (including identity columns)
2006
ISO/IEC 9075-14:2006 defines ways that SQL can be used with XML. It defines ways of importing and storing XML data in an SQL database, manipulating it within the database, and publishing both XML and conventional SQL-data in XML form. In addition, it lets applications integrate queries into their SQL code with XQuery, the XML Query Language published by the World Wide Web Consortium (W3C), to concurrently access ordinary SQL-data and XML documents.
2008
Legalizes ORDER BY outside cursor definitions. Adds INSTEAD OF triggers, TRUNCATE statement,[34] FETCH clause
2011
Adds temporal data (PERIOD FOR)[35] (more information at: Temporal database#History). Enhancements for window functions and FETCH clause.
2016
Adds row pattern matching, polymorphic table functions, JSON
2019
Adds Part 15, multidimensional arrays (MDarray type and operators)
https://en.wikibooks.org/wiki/Structured_Query_Language
https://en.wikibooks.org/wiki/MySQL
https://en.wikibooks.org/wiki/PostgreSQL
https://en.wikibooks.org/wiki/SQLite
https://en.wikipedia.org/wiki/SQL_reserved_words
最新的 SQL 标准一共分成 9 个部分(Part 5,6,7,8,12 可能是被废弃了):
PS: 前缀 ISO/IEC 9075-<n>:2016 – Information technology – Database languages – SQL –
省略。
PS: 还有一个拓展标准:ISO/IEC 13249 SQL Multimedia and Application Packages
多数数据库没有严格按照标准来实现,导致不通平台上的 SQL 语句是不能跨平台的。
以下是两种主要的 SQL 方言:
看了盗版电影,我有罪...
刚看了赵本山、闫妮的《过年好》,挺好的,本来赵本山那一伙人一出现就是烂片的印象被打破了。
一直忘不掉那个画面,妈妈(闫妮)和女儿吵架,姥爷(赵本山)在一旁默默的灌酒~
还有,那个好像有点傻的、一直在唱《一人我饮酒醉》的小天。
...
不过,为什么看海报上看起来好像是被当做是贺岁片在宣传呢?
和张国立、姚晨主演的《一切都好》类似的主题,本来都可以往文艺方向走的。
可能是文艺片在国内票房没市场吧,请来大腕拍电影,肯定是要算投资回报的。在年底的票房蛋糕中圈尽可能多的钱才是投资方的目标。明显,包装成贺岁片才能实现这个目标。
一人我饮酒醉
醉把那佳人成双对
两眼是独相随
我只求他日能双归
Excel 文件 > Sheet(工作表) > 行和列
!Sheetname
[filename]
=A1
相对引用=$A$1
绝对引用=A$1
列相对引用+行绝对引用=$A1
行相对引用+列绝对引用+
、-
、*
、/
、(
、)
?
单个字符*
多个字符=A1&B1
字符串连接NOW
AND
、OR
、NOT
、XOR
LOOKUP
、MATCH
、INDEX
VLOOKUP
XLOOKUP
HLOOKUP
SUM
求和SUMIF
SUMIFS
MAX
、MIN
、AVERAGE
、MEDIAN
最大,最小,平均值,中位数MAXA
MAXIFS
MINA
MINIFS
AVERAGEIF
AVERAGEIFS
COUNT
计数COUNTIF
COUNTIFS
COUNTA
COUNTBLANK
PRODUCT
(a1 * b1 * a2 * b2 * ...
)SUBPRODUCT
(a1 * b1 + a2 * b2 + ...
)STDEV
STDEVA
STDEVP
STDEVPA
STDEV.P
STDEV.S
VAR
VARA
VARP
VARPA
VAR.P
VAR.S
Alt
+ Enter
换行Ctrl
+ ;
输入日期Ctrl
+ Shift
+ ;
输入时间Ctrl
+ Z
/ 重做 Ctrl
+ Y
一共 34 个省级行政区:
河北 河南
湖北 湖南 江西
广东 广西 福建 海南
山东 山西
辽宁 吉林 黑龙江
新疆 西藏 内蒙古
陕西 甘肃 青海 宁夏
四川 重庆
贵州 云南
江苏 浙江 安徽
香港 澳门 台湾
北京 天津 上海
CREATE [UNIQUE | FULLTEXT | SPATIAL] INDEX index_name
[index_type]
ON tbl_name (key_part,...)
[index_option]
[algorithm_option | lock_option] ...
key_part:
col_name [(length)] [ASC | DESC]
index_option: {
KEY_BLOCK_SIZE [=] value
| index_type
| WITH PARSER parser_name
| COMMENT 'string'
}
index_type:
USING {BTREE | HASH}
algorithm_option:
ALGORITHM [=] {DEFAULT | INPLACE | COPY}
lock_option:
LOCK [=] {DEFAULT | NONE | SHARED | EXCLUSIVE}
聚簇索引(Clustered Index)是一种特殊的索引类型,它决定了表中数据的物理存储顺序。
在聚簇索引中,数据行按照索引键的顺序存储在磁盘上,因此具有相邻的物理位置,这样可以提高查询效率。
聚簇索引只能有一个,因为它决定了表中数据的物理存储顺序,如果有多个聚簇索引,就会导致数据在磁盘上存储的位置不确定,影响查询效率。
其他索引叫二级索引(Secondary Index),或者辅助索引。
对于 InnoDB,有限使用主键做聚簇索引,其次找一个不含 NULL 值的唯一索引,还没有,就自动生成一个隐式的自增型 ROW_ID 字段(BIGINT UNSIGNED
)做聚簇索引 GEN_CLUST_INDEX。
注意:所有索引在提升查询效率的同时,都会影响插入和删除的性能。尤其是聚簇索引需要重新组织数据行的物理存储顺序。
import tempfile
import time
timestr = time.strftime("%Y%m%d%H%M%S")
# tempfile.mktemp(suffix='', prefix='tmp', dir=None)
# tempfile.mkstemp(suffix=None, prefix=None, dir=None, text=False)
filepath_temp = tempfile.mktemp(suffix='.html', prefix='.cache_%s_' % timestr)
print(filepath_temp)
# /tmp/.cache_20210929205452_zlmi3pkf.html
filepath_temp = tempfile.mktemp(suffix='.html', prefix='.cache_%s_' % timestr,
dir='/opt/apps/markjour/tmp/')
print(filepath_temp)
# /opt/apps/markjour/tmp/.cache_20210929205452_mcr7nj3e.html
filepath_temp = tempfile.mkstemp(suffix='.html', prefix='.cache_%s_' % timestr, text=True)
mkstemp
和 mktemp
的区别:mkstemp
返回一个文件描述符,mktemp
返回一个文件路径。
mktemp
返回的路径理论上会被另一个进程使用,所以这是 UNSAFE 的,应该用 mkstemp
代替。
mktemp
从 Python 2.3 开始标记为 Deprecated,但是至今还是可以调用。
# tempfile.mkdtemp(suffix=None, prefix=None, dir=None)
dirpath_temp = tempfile.mkdtemp()
print(dirpath_temp)
# /tmp/tmp1dj2cl0d
dirpath_temp = tempfile.mkdtemp(prefix='build_',
dir='/opt/apps/markjour/tmp/')
print(dirpath_temp)
# /opt/apps/markjour/tmp/build_9k5synh5
import zipfile
import os
zip_path = "/path/to/zip/file.zip"
extract_path = "/path/to/extract/directory"
if not os.path.exists(extract_path):
os.makedirs(extract_path)
with zipfile.ZipFile(zip_path, 'r') as fp:
# 直接解压
zip_ref.extractall(target_dir)
# 逐个解压
for filename in fp.namelist():
# 如果文件存在就先移除,避免 FileExistsError
extract_file_path = os.path.join(extract_path, filename)
if os.path.exists(extract_file_path):
# print("跳过解压缩文件:", filename)
# continue
os.remove(extract_file_path)
# 解压,会自动创建目录结构
fp.extract(filename, extract_path)
File Descriptor
“一切皆文件” 设计思想来自早期 Unix,这是现在 Unix/Linux 界的一个非常重要的概念(根据 Plan9 操作系统的相关资料,这一条没有得到彻底的贯彻)。
cat /proc/sys/fs/file-nr
# 17781 0 9223372036854775807
# 已分配, 已使用, 最大值
cat /proc/sys/fs/file-max
# 9223372036854775807
sudo sysctl -a | grep file
# fs.file-max = 9223372036854775807
# fs.file-nr = 17813 0 9223372036854775807
修改:
echo 100000000 > /proc/sys/fs/file-max
sysctl fs.file-max 100000000
# ulimit 是一个 Shell 内建命令
ulimit -a # 输出所有的相关限制
ulimit -n # 当前进程的最大打开文件数
ulimit -n 10240 # 修改当前进程的最大打开文件数
ps -ef | grep sshd | grep -Fv 'grep '
root 1080 1 0 10月16 ? 00:00:00 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups
sudo ls -l /proc/`pgrep sshd`/fd
总用量 0
lr-x------ 1 root root 64 10月 17 12:04 0 -> /dev/null
lrwx------ 1 root root 64 10月 17 12:04 1 -> 'socket:[25487]'
lrwx------ 1 root root 64 10月 17 12:04 2 -> 'socket:[25487]'
lrwx------ 1 root root 64 10月 17 12:04 3 -> 'socket:[28674]'
lrwx------ 1 root root 64 10月 17 12:04 4 -> 'socket:[28676]'
echo "* soft nofile 65535" | sudo tee -a /etc/security/limits.conf
echo "* hard nofile 65535" | sudo tee -a /etc/security/limits.conf
系统会根据 /etc/pam.d/login 中的 PAM 配置来为登录用户设置,
如果配置了 session required /lib/security/pam_limits.so
, 就会加载 /etc/security/limits.conf
设置用户的各种限制值。
<domain> <type> <item> <value>
@group
syntax*
, for default entry%
, can be also used with %group
syntax, for maxlogin limitcore
- limits the core file size (KB)data
- max data size (KB)fsize
- maximum filesize (KB)memlock
- max locked-in-memory address space (KB)nofile
- max number of open file descriptorsrss
- max resident set size (KB)stack
- max stack size (KB)cpu
- max CPU time (MIN)nproc
- max number of processesas
- address space limit (KB)maxlogins
- max number of logins for this usermaxsyslogins
- max number of logins on the systempriority
- the priority to run user process withlocks
- max number of file locks the user can holdsigpending
- max number of pending signalsmsgqueue
- max memory used by POSIX message queues (bytes)nice
- max nice priority allowed to raise to values: [-20, 19]
rtprio
- max realtime prioritychroot
- change root to directory (Debian-specific)