新星计划2023SQL SERVER (01) -- 基础知识
Posted 百世经纶『一页書』
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了新星计划2023SQL SERVER (01) -- 基础知识相关的知识,希望对你有一定的参考价值。
【新星计划2023】SQL SERVER -- 基础知识
1. Introduction
1.1 Official Website
- 官方文档(小技巧)
Officail Website: https://learn.microsoft.com/en-us/sql/sql-server/?view=sql-server-ver16.
Officail Website(中文): https://learn.microsoft.com/zh-cn/sql/sql-server/?view=sql-server-ver16.
1.2 Conn Tool
- 官方自带的
SQL Server Management Studio (SSMS)
SSMS Install: https://learn.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms?view=sql-server-ver16.
- 我自己使用的
Dbeaver
Dbeaver Install: https://dbeaver.io/.
2. 基础命令
2.1 建库建表
// create database
CREATE DATABASE database_name;
// create schema
CREATE SCHEMA schema_name AUTHORIZATION dbo;
//create table(主键自增)
CREATE TABLE database_name.schema_name.table_name | schema_name.table_name | table_name (
stu_id int IDENTITY(1,1) NOT NULL,
department_id int,
stu_province nvarchar(50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
stu_city nvarchar(50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
stu_town nvarchar(50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
stu_address nvarchar(200) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
stu_score int,
CONSTRAINT PK__STUDENG__8379F1C4D400EC53 PRIMARY KEY (stu_id)
);
2.2 Alter
//add column
ALTER TABLE STUDENT ADD stu_hobby nvarchar(200) not null default 0;
// 修改栏位名
ALTER TABLE STUDENT rename column A to B;
// 修改栏位类型
ALTER TABLE STUDENT alter column A type not null;
// 删除栏位
ALTER TABLE STUDENT drop column A;
// 添加主键
ALTER TABLE STUDENT ADD CONSTRAINT PK_STUDENT PRIMARY KEY(stu_id);;
2.3 Drop
// delete database
DROP DATABASE DatabaseName;
// delete schema
DROP SCHEMA schema_name ;
// delete table
DROP TABLE dbo.STUDENT;
// delete column
ALTER TABLE STUDENT drop column A;
// query primary key
SELECT name FROM sys.key_constraints WHERE type = 'PK' ANDOBJECT_NAME(parent_object_id) = N'tablename';
// delete primary key
ALTER TABLE STUDENT DROP CONSTRAINT PKname;
2.3 Big Data – Postgres
3.Awakening
在一秒钟内看到本质的人和花半辈子也看不清一件事本质的人,自然是不一样的命运。
[新星计划]OneKey_一键启动集群 启动Kafka/Zookeeper命令
Kafka一键启动脚本:
cat /export/onekey/slave | while read line
do
{
echo $line
ssh $line "source /etc/profile;export JMX_PORT=9988;nohup ${KAFKA_HOME}/bin/kafka-server-start.sh ${KAFKA_HOME}/config/server.properties >/dev/nul* 2>&1 & "
}&
wait
done
Kafka一键关闭脚本:
cat /export/onekey/slave | while read line
do
{
echo $line
ssh $line "source /etc/profile;jps |grep Kafka |cut -d' ' -f1 |xargs kill -s 9"
}&
wait
done
nohup bin/zookeeper-server-start.sh config/zookeeper.properties &
#!/bin/bash
ZK_HOME=/export/server/zookeeper-3.4.6
for number in {1..3}
do
host=node${number}
echo ${host}
/usr/bin/ssh ${host} "cd ${ZK_HOME};source /etc/profile;${ZK_HOME}/bin/zkServer.sh start"
echo "${host} started"
done
一键启动集群脚本:
#!/bin/bash
p=$1
cmd=''
if [ ! $p ]
then echo "please input [start|stop]"
exit 1
fi
if [ $p == 'start' ]
then
cmd='start'
else
cmd='stop'
fi
#start hadoop
/export/server/hadoop/sbin/${cmd}-all.sh >> /export/server/hadoop/${cmd}.log
sleep 3s
#start zookeeper
for (( i=1; i<=3; i++ ))
do
# << E0F 只是一个标识,可以换做其他任意字符,多行复杂脚本使用
echo "node$i zk ${cmd} ..."
ssh root@node$i "source /etc/profile; zkServer.sh ${cmd} ;exit; sleep 2s"
done
echo "zk集群${cmd} 完成."
sleep 1s
# start kafka
for (( i=1; i<=3; i++ ))
do
echo "node$i kafka ${cmd} ..."
ssh root@node$i "source /etc/profile; kafka-server-${cmd}.sh -daemon /export/server/kafka/config/server.properties; exit; sleep 1s;"
done
# start flink
/export/server/flink/bin/${cmd}-cluster.sh
以上是关于新星计划2023SQL SERVER (01) -- 基础知识的主要内容,如果未能解决你的问题,请参考以下文章
新星计划·2023-第1期 - Python赛道报名入口 -〖你就是下一个新星〗
〖2023·新星计划·第四季〗开启,Python赛道火爆预热中~ 欢迎小伙伴们报名~
2023·新星计划 - 为什么头部博主们写的内容有那么多人追捧?他们是掌握了什么流量密码?