SQL is a language used to create, manipulate, and retrieve data stored in relational databases. The document provides examples of SQL commands to create a table, insert data, select data with conditions and ordering, aggregate data, join related tables, and update and delete data.
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
20 views
Criando Tabelas
SQL is a language used to create, manipulate, and retrieve data stored in relational databases. The document provides examples of SQL commands to create a table, insert data, select data with conditions and ordering, aggregate data, join related tables, and update and delete data.
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1
SQL
Criando tabelas
CREATE TABLE customers (id INTEGER PRIMARY KEY, name TEXT, age INTEGER, weight REAL);
Insero de dados
INSERT INTO customers VALUES (73, "Brian", 33);
Consultando dados
SELECT * FROM customers; (selecionando tudo)
SELECT * FROM customers WHERE age < 21 AND state = "NY"; (selecionando com condies) SELECT name, age FROM customers; (selecionando colunas especficas) SELECT name, CASE WHEN age > 18 THEN "adult" ELSE "minor" END "type" FROM customers; (transformar com CASE) SELECT * FROM customers WHERE age > 21 ORDER BY age DESC; (ordenar resultados)
Agregando dados
SELECT MAX(age) FROM customers;
SELECT gender, COUNT(*) FROM students GROUP BY gender; (arupamento de dados)
Associando tabelas relacionadas
SELECT customers.name, orders.item FROM customers JOIN orders ON
(Practical Resources for the Mental Health Professional) Sharon L. Johnson-Therapist's Guide to Clinical Intervention, Second Edition_ The 1-2-3's of Treatment Planning (Practical Resources for the Me(1).pdf