国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Table of Contents
Common sql commands for operating database structure and data
Using database" >Using database
Create table" >Create table
Show" > Show
##Delete" >##Delete
# Add, delete, and modify the data structure check (Basically based on the modified keyword "alter")" ># Add, delete, and modify the data structure check (Basically based on the modified keyword "alter")
Data addition, deletion and modification query " >Data addition, deletion and modification query
Home Database Mysql Tutorial SQL commands commonly used in database operations

SQL commands commonly used in database operations

Sep 07, 2017 pm 03:51 PM
sql Order database

Common sql commands for operating database structure and data

Create database

create database if not exists  數(shù)據(jù)庫名  charset=指定編碼

Using database

use 數(shù)據(jù)庫名

Create table

create table if not exists 表名(
字段名 類型名,       
id  int,        
birth  date  
);

Show

顯示表(創(chuàng)建表代碼)
 show create table 表名字;
顯示表結(jié)構(gòu)
 desc 表名;
顯示數(shù)據(jù)庫和表
 show 數(shù)據(jù)庫名/表名
rrree

##Delete

<br/>

# Add, delete, and modify the data structure check (Basically based on the modified keyword "alter")

刪除數(shù)據(jù)庫與表
drop 數(shù)據(jù)庫名/表名
添加列
alter table 表名 add(列名 列類型,列名 列類型);
alter table tab_day1 add(age int,zwjs text);
刪除列
alter table 表名 drop 列名;
alter table tab_day1 drop age;

Data addition, deletion and modification query

(這里區(qū)別change與modify,change為改變的意思,程度自然比modify大)
修改列名
alter table tab_day1 change 舊列名 新列名 新列類型;
alter table tab_day1 change money salary decimal(10,2);
修改列類型
alter table tab_day1 modify 列名 列新類型;
alter table tab_day1 modify height int;

The above is the detailed content of SQL commands commonly used in database operations. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1502
276
Redis vs databases: what are the limits? Redis vs databases: what are the limits? Jul 02, 2025 am 12:03 AM

Redisislimitedbymemoryconstraintsanddatapersistence,whiletraditionaldatabasesstrugglewithperformanceinreal-timescenarios.1)Redisexcelsinreal-timedataprocessingandcachingbutmayrequirecomplexshardingforlargedatasets.2)TraditionaldatabaseslikeMySQLorPos

What is the purpose of the DISTINCT keyword in a SQL query? What is the purpose of the DISTINCT keyword in a SQL query? Jul 02, 2025 am 01:25 AM

The DISTINCT keyword is used in SQL to remove duplicate rows in query results. Its core function is to ensure that each row of data returned is unique and is suitable for obtaining a list of unique values ??for a single column or multiple columns, such as department, status or name. When using it, please note that DISTINCT acts on the entire row rather than a single column, and when used in combination with multiple columns, it returns a unique combination of all columns. The basic syntax is SELECTDISTINCTcolumn_nameFROMtable_name, which can be applied to single column or multiple column queries. Pay attention to its performance impact when using it, especially on large data sets that require sorting or hashing operations. Common misunderstandings include the mistaken belief that DISTINCT is only used for single columns and abused in scenarios where there is no need to deduplicate D

What is the difference between WHERE and HAVING clauses in SQL? What is the difference between WHERE and HAVING clauses in SQL? Jul 03, 2025 am 01:58 AM

The main difference between WHERE and HAVING is the filtering timing: 1. WHERE filters rows before grouping, acting on the original data, and cannot use the aggregate function; 2. HAVING filters the results after grouping, and acting on the aggregated data, and can use the aggregate function. For example, when using WHERE to screen high-paying employees in the query, then group statistics, and then use HAVING to screen departments with an average salary of more than 60,000, the order of the two cannot be changed. WHERE always executes first to ensure that only rows that meet the conditions participate in the grouping, and HAVING further filters the final output based on the grouping results.

How to select a different database in Redis? How to select a different database in Redis? Jul 05, 2025 am 12:16 AM

ToswitchdatabasesinRedis,usetheSELECTcommandfollowedbythenumericindex.Redissupportsmultiplelogicaldatabases(default16),andeachclientconnectionmaintainsitsownselecteddatabase.1.UseSELECTindex(e.g.,SELECT2)toswitchtoanotherdatabase.2.Verifywithcommands

Performing database schema migrations in MySQL Performing database schema migrations in MySQL Jul 06, 2025 am 02:51 AM

Database schema migration refers to the process of modifying the database structure without changing the data, which mainly includes adding or deleting tables, modifying column types or constraints, creating or deleting indexes, changing default values ??or nullable settings, etc. It is usually driven by application updates, for example, when new features need to store user preferences, new columns are added to the user table. Unlike data migrations that deal with large amounts of data movement, pattern migration focuses on structural changes. To perform mode migrations safely, version control should be used to track structure files, verify them in the test environment before the production environment, split the large migration into small steps, avoid multiple irrelevant changes in a single time, and note that changes to large tables may cause long-term table locking problems. You can use tools such as pt-online-schema-chan.

How to create empty tables with the same structure as another table? How to create empty tables with the same structure as another table? Jul 11, 2025 am 01:51 AM

You can use SQL's CREATETABLE statement and SELECT clause to create a table with the same structure as another table. The specific steps are as follows: 1. Create an empty table using CREATETABLEnew_tableASSELECT*FROMexisting_tableWHERE1=0;. 2. Manually add indexes, foreign keys, triggers, etc. when necessary to ensure that the new table is intact and consistent with the original table structure.

Populating databases for development and testing with Laravel Populating databases for development and testing with Laravel Jul 03, 2025 am 01:31 AM

Laravel provides multiple ways to populate databases to support development and testing. 1. Use Seeder to insert fixed test data, suitable for small-scale data sets; 2. Use Factory to generate diverse and realistic data, suitable for simulating large amounts of records; 3. Real data can be exported and desensitized from the production environment to discover potential problems. The appropriate method should be selected according to the needs and used reasonably.

What is the difference between a clustered and a non-clustered index in SQL? What is the difference between a clustered and a non-clustered index in SQL? Jul 04, 2025 am 03:03 AM

Clusteredandnon-clusteredindexesdifferindataorganizationandusage.1.Clusteredindexesdefinethephysicalorderofdatastorage,allowingonlyonepertable,idealforrangequeries.2.Non-clusteredindexescreateaseparatestructurewithpointerstodatarows,enablingmultiplei

See all articles