Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MySQL basic statement

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Here does not introduce the MySQL function and other knowledge, only makes the basic grammar introduction explanation. Show databases; displays the database create databasename; creates the database create table user like user_info; creates the same table structure create table user as select * from user_info; creates the same table structure and replicates the data use databasename; selects the database drop databasename directly deletes the database without reminding mysqladmin drop databasename to delete the database. Select version (), now () displays the current mysql version and current date create table table_name (field 1 data type, field 2 data type); syntax for creating a data table alter table T1 rename T2; rename table show tables; display table show create table table_name; view table creation statement alter table table_name engine=innodb; modify storage engine desc tablename Show table structure alter table test add column t_name varchar (20) after tweeds; add table field Alter table test drop ts_wave delete field alter table test modify id int unsigned; modify table field type alter table patient add index index_code (pt_code); add index create unique index on tablenme (pt_code); create index drop index pt_code on tablename; delete index alter table test change ts_name tb_name varchar (20) Modify table fields and types alter table table_name rename to new_table_name; modify table name truncate table table_name; clear table data

① constraints (primary key Primary key, unique Unique, non-empty Not Null)

② auto-add auto_increment

③ foreign key Foreign key- is used in conjunction with reference table_name (col_name column name) and used separately when creating a table

Add data: Insert into tablename (COLUMNS1, COLUMNS2, … .)] Values (v1, v2, … ..); delete data: delete from tablename where. Modify data: update tablename set COLUMNS1=vs1 where. Query data: select columns from tablename where... Group by... Order by... Desc/asc having... Limit... UPDATE T1 SET col1 = col1 + 1, col2 = col1; col1 has the same value as col2

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report