In mysql, we only need to use alter to modify the data table fields. Below I will introduce how to modify the table field name, field length, and field type in mysql, for more information, see.
Let's take a look at common methods.
The simple Syntax
1. Display the list of databasesshow databases; # View all current databasesShow Databases \g #以行的方式显示2. On the command line, execute the SQL statementMysql-e ' show databases '-uroot-p123456mysqlshow-uroot-p123456 # not used, just remember the one
PHP gets the MySQL data table field name and details method, MySQL field
First we need to understand the SQL statements that query MySQL database/table related information:
Copy the Code code as follows:SHOW DATABASES//Lists the MySQL Server
MySQL常用指令,java,php程序员,数据库工程师必备。程序员小冰常用资料整理MySQL common commands (for reference)The most common display commands are:1. Display the list of databases.show databases;2. Display the data table in the library:Use MySQL;Show tables;3, display the
Let's take a look at the usual methods.
MySQL's simple syntax, commonly used, but not easy to remember. Of course, these SQL syntaxes are basically generic in each database. Listed below:
1. Add a field
ALTER TABLE user add COLUMN new1 VARCHAR
MySQL field name conflicts with reserved words and the solution, mysql Field
Problem: Conflicts between MySQL field names and reserved words often occur in actual operations.
Com. mysql. jdbc. exceptions. jdbc4.MySQLSyntaxErrorException.
Solution:
Http://www.2cto.com/database/201202/121253.html 1, MySQL is case-sensitive by default, use show Variables like '%table_names ' to view Lower_ The value of the Case_table_names, 0 stands for the distinction, 1 represents not differentiated.2, MySQL
1. Whether mysql is case sensitive by default. Use show Variables like '% table_names' to check the lower_case_table_names value. 0 indicates yes, and 1 indicates no. 2. mysql is case insensitive for data of the varchar type by default. However, if
1. Add a field ALTER TABLE user add COLUMN new1 VARCHAR (x) DEFAULT NULL; Add a field that defaults to null ALTER TABLE user add COLUMN new2 VARCHAR (a) not NULL; Add a field, default cannot be empty//2. Delete a field ALTER TABLE
One: Field modifier1:null and NOT NULL modifiersLet's take a look at this example.Mysql> CREATE TABLE worker (ID int not null,name varchar (8) Not null,pass varchar (a) not null);Mysql> INSERT into worker values (1, ' HA ', ' 123456 ');Mysql> INSERT
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.