Este documento resume as principais informações sobre Vithor da Silva e Silva, um consultor e instrutor de SQL Server e Power BI. Ele possui certificações em SQL Server e IBM DB2 LUW e oferece treinamentos em SQL Server, Power BI e Linux. O documento também apresenta as principais características e benefícios do SQL Server, incluindo tecnologias como In-Memory OLTP, Query Store, Temporal Tables, Row-Level Security e Always Encrypted.
ATIVIDADE 1 - GCOM - GESTÃO DA INFORMAÇÃO - 54_2024.docx
FLISOL 2017 - SQL Server no Linux
1. SQL Server
Linux
Vithor da Silva e Silva
Microsoft Certified Trainer
vithor@vssti.com.br
http://www.vssti.com.br/blog/
https://twitter.com/vithordasilva
2. Sobre mim
• Vithor da Silva e Silva
• Consultor – Plataforma de Dados e BI – AX4B
• Instrutor – SQL Server e Power BI - Mindworks
• Certificado em SQL Server e IBM DB2 LUW;
• vithor@vssti.com.br
• www.vssti.com.br/blog
• https://br.linkedin.com/in/vithorsilva
• https://www.facebook.com/vithorsilva
• https://www.facebook.com/vssti
• https://www.facebook.com/sqles
6. 15 anos de Inovação
SQL Server
2000
SQL Server
2005
SQL Server
2008
SQL Server
2008 R2
SQL Server
2012
XML ● KPIs
Management Studio ● Espelhamento
Compactação ● Gerenciamento baseado em políticas ● Programação
PowerPivot ● Integração com o SharePoint ● Master Data Services
AlwaysOn ● Índice ColumnStore ● Data Quality Services ● Power View ● Conectividade de Nuvem
SQL Server
2014
In-Memory em todas as cargas de trabalho ● Desempenho e Escala ● Nuvem Híbrida Otimizada ● HDInsight ● BI de Nuvem
12. # Importar o Repositório Público
suporte@LAB002:~$ curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key
add -
# Registrar os repositórios Microsoft SQL Server Ubuntu
suporte@LAB002:~$ curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-
server.list | sudo tee /etc/apt/sources.list.d/mssql-server.list
suporte@LAB002:~$ curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo
tee /etc/apt/sources.list.d/msprod.list
# Atualização da Lista de Repositórios do Ubuntu
suporte@LAB002:~$ sudo apt-get update
# Instalação do SQL Server
suporte@LAB002:~$ sudo apt-get install -y mssql-server
# Configuração do SQL Server
suporte@LAB002:~$ sudo /opt/mssql/bin/mssql-conf setup
# Verificar Status do Serviço
suporte@LAB002:~$ systemctl status mssql-server
Instalação do SQL Server no Ubuntu Server
13. # Atualização da Lista de Repositórios do Ubuntu
suporte@LAB002:~$ sudo apt-get update
# Instalação do SQLCMD / BCP e ODBC para Linux
suporte@LAB002:~$ sudo apt-get install mssql-tools unixodbc-dev
# Adicionando os binários no PATH
suporte@LAB002:~$ echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
suporte@LAB002:~$ echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
suporte@LAB002:~$ source ~/.bashrc
# Acessando o SQL Server via Linha de Comando
suporte@LAB002:~$ sqlcmd -S . -U sa
Instalação do SQL Server no Ubuntu Server
18. Você já…?
…teve seu Sistema lento e todo mundo esperando que você desse uma
solução mágica o mais rápido possível?
…atualizou uma aplicação pra última versão do SQL e teve problemas
com o novo plano de execução que fez sua aplicação ficar mais lenta?
…teve um problema com sua base Azure SQL Database e não pôde
determinar o que estava errado?
19. Monitoramento de performance com Query Store
O query store provê aos
DBAs imersões nos
planos de queries
escolhidos
21. Fontes de dados reais são
dinâmicas
Dados históricos podem ser críticos para o sucesso
Databases tradicionais falham nessas imersões
Workarounds…
Complexos, caros, limitados, inflexíveis, ineficientes
SQL Server 2016 facilita…
Sem mudanças no modelo de implementação
Novas imersões
Por que Temporal?
Viagem no tempo Auditoria
Slowly Changing
Dimensions
Reparar
problemas em
nível de linha
22. Temporal table (dados atuais)
Insert / Bulk Insert
* Versões Antigas
Update */ Delete *
Como funciona?
History Table
23. Temporal table (dados atuais)
Temporal Queries *
(Time travel,etc.)
Como funciona?
History Table
Regular queries
(dados atuais)
* Inclui Versão Antiga
25. Two
Usuário(ex: enfermeiro) seleciona dados da tabela de pacientes
Three
Políticas de segurança reescreve a consulta de forma transparente para aplicar o
filtro
Database Policy Manager
CREATE FUNCTION dbo.fn_securitypredicate(@wing int)
RETURNS TABLE WITH SCHEMABINDING AS
return SELECT 1 as [fn_securitypredicate_result] FROM
StaffDuties d INNER JOIN Employees e
ON (d.EmpId = e.EmpId)
WHERE e.UserSID = SUSER_SID() AND @wing = d.Wing;
CREATE SECURITY POLICY dbo.SecPol
ADD FILTER PREDICATE dbo.fn_securitypredicate(Wing) ON Patients
WITH (STATE = ON)
Filter
Predicate:
INNER
JOIN…
Security
Policy
Aplicação
Pacientes
One
Policy manager cria predicados de filtro e políticas de segurança em T-SQL,
blindando a tabela Pacientes
Enfermeira
SELECT * FROM Patients
SELECT * FROM Patients
SEMIJOIN APPLY dbo.fn_securitypredicate(patients.Wing);
SELECT Patients.* FROM Patients,
StaffDuties d INNER JOIN Employees e ON (d.EmpId = e.EmpId)
WHERE e.UserSID = SUSER_SID() AND Patients.wing = d.Wing;
RLS em três passos
27. Configuração simples pelo portal Azure
Baseado em políticas em nível de tabelas e
colunas, por um grupo definido de usuários
Data masking aplicado em tempo real para
resultados de queries baseadas em políticas
Múltiplas funções masking disponíveis (full,
partial) para várias categorias de dados
sensíveis (ex: Cartões de crédito, SSN, etc.)
SQL Database
SQL Server 2016 CTP2
Table.CreditCardNo
4465-6571-7868-5796
4468-7746-3848-1978
4484-5434-6858-6550
Real-time data masking;
partial masking
Dynamic Data Masking
Previne contra o uso abusivo de dados sensíveis
29. Previne
Divulgação de
Dados
Proteção de dados sensíveis
no lado do cliente usando
chaves que nunca são dadas
ao Sistema de banco de
dados.
Queries em dados
Encriptados
Suporte para comparações
igualitárias, incluindo join,
group by e operdores
distinct.
Transparência de
Aplicação
Mudanças mínimas em
aplicações via servidor e
aprimoramento em
bibliotecas do cliente.
Permite clientes a guardar dados sensíveis de maneira segura fora de seu limite de confiança.
Dados se mantém protegidos de usuários com altos privilégios, porém não autorizados.
Benefícios de dados Sempre Encriptados
30. Data remains encrypted
during query
Always encrypted
Protege dados armazenados e em movimento, on-premises & cloud
Capacidade
ADO.Net client library provê criptografia
transparente do lado do cliente,
enquanto SQL Server executa as consultas
T-SQL em dados criptografados
Benefícios
Apps TCE-enabled
ADO .NET library
SQL ServerEncrypted
query
Columnar
key
No app
changes
Master
key
32. SQL Server “esticado” ao Azure
Estique tabelas frias ao Azure com processamento remoto de consultas
On-premises Azure
Pedidos
In-memory
OLTP table Histórico de
pedidos
Tabela esticada
Movimentação de dados e
processamento de consulta
remota
Dados
quentes/Ativos
Dados frios
Integração BI
on-premises
e cloud
33. SELECT * FROM Department
FOR SYSTEM_TIME
AS OF '2010.01.01'
Fatos:
1. Histórico é muito maior que dados
atuais
2. Retenção entre 3 e 10 anos
3. “Warm”: até poucas semanas/mêses
4. “Cold”: raramente consultados
Solução:
History como uma stretch table:
PeriodEnd < “Agora- 6 months”
Azure SQL Database
35. Mantenha-se informado, tudo sobre SQL Server e Power BI
www.vssti.com.br/blog
https://www.youtube.com/channel/UCj1O1SCoSyzrX1lX5HFb_8A
http://www.facebook.com/sqles
https://t.me/sqles
http://www.facebook.com/vssti
27 9 9903-2765
vithor@vssti.com.br
200 dólares o MCSA ou uns 800 reais
Só uma prova da Oracle são quase 600 reais, no total são quase 1000 reais mais um curso obrigatório.
Foi o banco de dados que ganhou mais popularidade em 2016, destacar a importância dele agora rodando no Linux para popularização.
systemctl set-default multi-user.target
https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-ubuntu
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add –
curl https://packages.microsoft.com/config/ubuntu/16.04/mssql-server.list | sudo tee /etc/apt/sources.list.d/mssql-server.list
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/msprod.list
https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup-tools#ubuntu
Ensinar a galera a instalar o Visual Code
How many of you had perf issues with SQL that slowed down the whole system – urgent to be fixed
How many of you had upgrade issues with plan regressions? Give me examples?
Had Azure perf issues?
Query plan choice changes can cause these problems
Source: https://msdn.microsoft.com/en-us/library/dn817826(v=sql.130).aspx
The point of this slide is to emphasize that Query Store comes with extraordinary UI that will help broader set of users to benefit from collected perf data immediately.
SSMS is focused around handful really the most important scenarios making feature instantly useful in everyday activities of typical DBA.
We want to encourage people to try out new UI and learn from it: it is a great knowledge source because people can easily learn first steps of using Query Store DMVs by analyzing queries generated by SSMS.
Source: https://msdn.microsoft.com/en-us/library/dn935015(v=sql.130).aspx
A temporal table is a new type of table that provides correct information about stored facts at any point in time. Each temporal table consists of two tables actually, one for the current data and one for the historical data. The system automagically ensures that when the data changes in the table with the current data the previous values are stored in the historical table. Querying constructs are provided to hide this complexity from users. For more information, see Temporal Tables.
Introduction to Key Components and Concepts
What is a Temporal Table?
A temporal table is a table for which a PERIOD definition exists and which contains system columns with a datatype of datetime2 into which the period of validity is recorded by the system, and which has an associated history table into which the system records all prior versions of each record with their period of validity. With a temporal table, the value of each record at any point in time can be determined, rather than just the current value of each record. A temporal table is also referred to as a system-versioned table.
Why Temporal?
Real data sources are dynamic and more often than not business decisions rely on insights that analysts can get from data evolution. Use cases for temporal tables include:
Understanding business trends over time
Tracking data changes over time
Auditing all changes to data
Maintaining a slowly changing dimension for decision support applications
Recovering from accidental data changes and application errors
Source: https://msdn.microsoft.com/en-us/library/dn935015(v=sql.130).aspx
The SYSTEM_TIME period columns used to record the SysStartTime and SysEndTime values must be defined with a datatype of datetime2.
Source: https://msdn.microsoft.com/en-us/library/dn935015(v=sql.130).aspx
The SYSTEM_TIME period columns used to record the SysStartTime and SysEndTime values must be defined with a datatype of datetime2.
Policy manager creates a filter predicate and security policy
App user (e.g., a nurse) selects from the Patients table
The query is transparently rewritten to apply the filter predicate
Notice: No app changes!
Source: https://msdn.microsoft.com/en-us/library/mt130841(v=sql.130).aspx
Dynamic data masking limits sensitive data exposure by masking it to non-privileged users. Dynamic data masking helps prevent unauthorized access to sensitive data by enabling customers to designate how much of the sensitive data to reveal with minimal impact on the application layer. It’s a policy-based security feature that hides the sensitive data in the result set of a query over designated database fields, while the data in the database is not changed. Dynamic data masking is easy to use with existing applications, since masking rules are applied in the query results, and there is no need to modify existing queries.
For example, a call center support person may identify callers by several digits of their social security number or credit card number, but those data items should not be fully exposed to the support person. A developer can define a masking rule to be applied to each query result that masks all but the last four digits of any social security number or credit card number in the result set. For another example, by using the appropriate data mask to protect personally identifiable information (PII) data, a developer can query production environments for troubleshooting purposes without violating compliance regulations.
Dynamic data masking limits the exposure of sensitive data and prevents accidental viewing by engineers that access directly databases for troubleshooting purposes or non-privileged application users. Dynamic data masking doesn’t aim to prevent privileged database users from connecting directly to the database and running exhaustive queries that expose pieces of the sensitive data. Dynamic data masking is complimentary to other SQL Server security features (auditing, encryption, row level security…) and it is highly recommended to enable them in addition in order to protect better the sensitive data in the database.
Since data is masked just before being returned to the user, changing the data type to an unmasked type will return unmasked data.
Dynamic data masking is available in SQL Server 2016 Community Technology Preview 2 (CTP2). However, to enable dynamic data masking, you must use trace flags 209 and 219. For Azure SQL Database, see Get started with SQL Database Dynamic Data Masking (Azure Preview portal).
Source: Source: https://msdn.microsoft.com/en-us/library/mt163865(v=sql.130).aspx
When it comes to mission critical security we are introducing a unique encryption technology that protects data at rest and in motion and can be full queried while encrypted. The new ADO .NET library provide transparent client-side ecryption, while SQL Server executes T-SQL queries on encrypted data. The master keys stay with the application and not with SQL Server. This can work on-premises or SQL Server in Azure VM. So think about the hybrid scenarios where you wanted to take advantage of Azure cloud computing, but for certain data could not take advantage of cloud scale due to data security requirements. This technology ensures your data is always encrypted. Best of all no application changes are required.
Source: http://channel9.msdn.com/Shows/Data-Exposed/Temporal-in-SQL-Server-2016
Example of using temporal tables with Azure SQL Database stretch tables.
Arquivos de demonstração em
http://www.vssti.com.br/blog/wp-content/uploads/2017/04/demos-flisol2017.zip
Arquivos de demonstração em
http://www.vssti.com.br/blog/wp-content/uploads/2017/04/demos-flisol2017.zip