View allAll Photos Tagged SQL
Complete reliable solution to fix SQL runtime server error and with that big data size of MDF File.
Read the blog.
Advanced SQL Azure training is a four-day course that provides advanced knowledge of SQL Azure, and the database cloud offering in Windows Azure. This course will drive the training from the basics around server and database provisioning, valid Azure TSQL, and learn how security is implemented and managed. Thereafter, the advanced topics will include partitioning with sharding, database design optimisation, backup and synchronisation via Synchronisation Framework and Azure Data Sync and migrating various database scenarios to SQL Azure.
Taller SQL Server 2008 Select & Inner Join dictado a la UPS Fabricio Ojeda, en el sector Monterrey El Valle el 5 de Abril de 2013
SQL được chia thành nhiều nhóm lệnh khác nhau như:
Nhóm định nghĩa cấu trúc dữ liệu (DDL).
Nhóm lệnh thao tác dữ liệu (DML).
Nhóm lệnh phân quyền sử dụng dữ liệu (DCL).
Nhóm lệnh thao tác với transaction (TCL).
Bài hôm nay chúng ta sẽ cùng tìm hiểu về các câu lệnh ở DDL.
1. Vai trò của các câu lệnh DDL trong SQL
Với nhóm lệnh DDL sẽ ứng dụng cho việc xây dựng cấu trúc, định nghĩa dữ liệu ở DB. Và để dễ dàng thiết lập DB về sau.
[Database] DDL
2. Hướng dẫn sử dụng các câu lệnh thông dụng ở DDL
2.1. Câu lệnh CREATE
Thường sử dụng để tạo cấu trúc của table, về sau này có thể sử dụng cho khái niệm nâng cao như tạo VIEW, TRIGGER, STORED PROCEDURE, FUNCTION…
Cú pháp
CREATE TABLE table_name (
column1 datatype,
column2 datatype,
column3 datatype,
....
);
Ví dụ
CREATE DATABASE hospital_management;
USE hospital_management;
CREATE TABLE doctor (
doctor_id INT,
first_name VARCHAR(10),
middle_name VARCHAR(10)
);
Với ví dụ trên, mình đang sử dụng CREATE để lần lượt tạo DB là quản lý bệnh viện. Và sau đó tiếp tục sử dụng để tạo table doctor, với 3 column là doctor_id (mã bác sĩ), first_name (tên bác sĩ), middle_name (tên lót của bác sĩ).
2.2. Câu lệnh ALTER
Khi các bạn muốn cập nhật lại cấu trúc của table, thì hãy nghĩ ngay đến câu lệnh ALTER. Ngoài ra, với những khái niệm nào thường được sử dụng với CREATE, thì sẽ sử dụng được với ALTER.
Cú pháp
Thêm một cột
ALTER TABLE table_name
ADD column_name datatype;
Xoá một cột
ALTER TABLE table_name
DROP COLUMN column_name;
Đổi tên cột
ALTER TABLE table_name
RENAME COLUMN old_name to new_name;
Sửa đổi kiểu dữ liệu của cột
ALTER TABLE table_name
MODIFY COLUMN column_name datatype;
Ví dụ
Ở ví dụ về CREATE, mình đã tạo ra table là doctor. Nhưng đang thiếu trường last_name là họ của bác sĩ, vậy mình sẽ tiến hành cập nhật theo lệnh bên dưới:
ALTER TABLE doctor
ADD last_name VARCHAR(10);
2.3. Câu lệnh DROP
Với các table không được sử dụng nữa, thì cần thực hiện xoá đi với câu lệnh DROP, nó sẽ xoá toàn bộ cấu trúc và dữ liệu của table ra khỏi DB.
Cú pháp
DROP TABLE table_name;
Ngoài ra, nếu bạn chỉ muốn xoá dữ liệu thôi, thì có thể sử dụng:
TRUNCATE TABLE table_name;
Ví dụ
DROP TABLE doctor;
Kết luận
Tóm lại với các bộ lệnh ở DDL, thì thường được sử dụng cho các thao tác liên quan đến cấu trúc trong DB và cú pháp cũng không khó để sử dụng:
Tạo mới cấu trúc: CREATE
Chính sửa cấu trúc: ALTER
Xoá cấu trúc: DROP
Nguồn: codegym.vn/blog/2023/11/18/cac-cau-lenh-thong-dung-o-ddl/
La Master Class SQL Server, c'est 5 des meilleurs spécialistes français de SQL Server qui animent chacun un jour complet de workshop sur leur domaine d’expertise. Durant cette semaine exceptionnelle, vous avez l’occasion d’accéder aux connaissances les plus pointues sur l’optimisation et le diagnostic SQL Server, en profitant de l’expérience et de la pédagogie des meilleurs.
Chronos Inventory Software - Step to manual set up the SQL Server database for eStockCard. Please visit our website at www.estockcard.com for more info on the eStockCard
You must have heard about the top skills required for Data Science. Do you know where you should start? The easier and most important skill that you can acquire is SQL. Before developing this skill, you must know the role of SQL in data science and why every Data Science expert mark SQL as an important one for data scientists. So, let’s explore how exactly SQL is crucial for data science.