systemctl start mssql-server
systemctl restart mssql-server
systemctl stop mssql-server
systemctl status mssql-server
/opt/mssql/bin/mssql-conf
SQLServer数据库和MySQL数据库的基本SQL命令是一样的,如下所示:
(1)创建数据库的SQL命令
> create database datax
> go
注意:SQLServer数据库(Linux环境下)在执行sql语句后,需要执行
go
命令以帮助真正实现前面执行的SQL命令,切记,切记,切记!!!
(2) 查看当前数据库列表有哪些
查询
SysDatabases
表即可得到相应的结果
> select * from SysDatabases
> go
(3) 查看当前数据表
此操作需要查看的是
sysobjects
表并制定过滤条件xtype='u'
来得到清晰的结果
> use 数据库名
> select * from sysobjects where xtype='u'
> go
(4)查看表的数据
> select * from 对应数据库的表名称;
> go
> create table student(id int,name varchar(25))
> go
> insert into student values(1,'zhangsan') go
[whybigdata@node01 datax]$ vim job/sqlserver2hdfs.json
json文件内容应该为如下:
{
"job": {
"content": [
{
"reader": {
"name": "sqlserverreader",
"parameter": {
"column": [
"id",
"name"
],
"connection": [
{
"jdbcUrl": [
"jdbc:sqlserver://node02:1433;DatabaseName=datax"
],
"table": [
"student"
]
}
],
"password": "asdfghj000.",
"username": "SA"
}
},
"writer": {
"name": "hdfswriter",
"parameter": {
"column": [
{
"name": "id",
"type": "int"
},
{
"name": "name",
"type": "string"
}
],
"defaultFS": "hdfs://node01:8020",
"fieldDelimiter": "=",
"fileName": "sqlserver.txt",
"fileType": "text",
"path": "/datax-out",
"writeMode": "append"
}
}
}
],
"setting": {
"speed": {
"channel": "1"
}
}
}
}
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Hhqq7kTF-1676007756548)(3.png)]
[whybigdata@node01 datax]$ vim job/sqlserver2mysql.json
json文件内容如下所示:
{
"job": {
"content": [
{
"reader": {
"name": "sqlserverreader",
"parameter": {
"column": [
"id",
"name"
],
"connection": [
{
"jdbcUrl": [
"jdbc:sqlserver://node02:1433;DatabaseName=datax"
],
"table": [
"student"
]
}
],
"username": "root",
"password": "123456"
}
},
"writer": {
"name": "mysqlwriter",
"parameter": {
"column": [
"*"
],
"connection": [
{
"jdbcUrl": "jdbc:mysql://node01:3306/datax",
"table": [
"student"
]
}
],
"password": "asdfghj000.",
"username": "SA",
"writeMode": "insert"
}
}
}
],
"setting": {
"speed": {
"channel": "1"
}
}
}
SQLServer数据导入MySQL之前MySQL中表的数据如下所示:
SQLServer数据导入MySQL之后MySQL中表的数据如下所示:
可以观察到,SQLServer数据成功导入到MySQL中。
DataX和SQLServer的数据导入导出其实并不难,同样的还是编写正确的json文件,之后的操作就i是家常便饭。
DataX和SQLServer之间的数据导入导出案例,全文结束!