How to add fields and comments to a table in sql

How to add fields and comments to a table in sql

1. Add fields:

alter table table name ADD field name type;

eg:

alter table sys_cwzd ADD SCCLLJ VARCHAR2(50);

2. Add remarks:

comment on column table name. Field name is 'remark name';

eg:

comment on column sys_cwzd.SCCLLJ is 'Upload material path';

Content extension:

Add a new field:

alter table bulletin add citycode varchar(6) not null default 0; # city code

1. Set the encoding when creating the database

create database test character set utf8;

2. Set the encoding when creating a table

create table test(id int primary key)DEFAULT charset=utf8;

3. Modify the database encoding

alter database test character set utf8;

4. Modify the default encoding of the table

alter table test character set utf8;

You may also be interested in:
  • Several ways to add timestamps in MySQL tables
  • How to add indexes to MySQL
  • MYSQL implements sample code to prevent duplicate addition when adding shopping cart
  • How to create a stored procedure in MySQL and add records in a loop
  • Summary of MySQL's commonly used SQL statements for creating tables, adding fields, modifying fields, and adding indexes

<<:  Detailed explanation of Vue's methods and properties

>>:  CentOS 6 uses Docker to deploy Zookeeper operation example

Recommend

MySQL DeadLock troubleshooting full process record

【author】 Liu Bo: Senior Database Manager at Ctrip...

How to implement n-grid layout in CSS

Common application scenarios The interfaces of cu...

Native js to implement drop-down box selection component

This article example shares the specific code of ...

Should the Like function use MySQL or Redis?

Table of contents 1. Common mistakes made by begi...

Axios cancel request and avoid duplicate requests

Table of contents origin status quo Cancel reques...

Reasons and solutions for MySQL selecting the wrong index

In MySQL, you can specify multiple indexes for a ...

How to quickly install tensorflow environment in Docker

Quickly install the tensorflow environment in Doc...

Implementation of IP address configuration in Centos7.5

1. Before configuring the IP address, first use i...

An article teaches you to write clean JavaScript code

Table of contents 1. Variables Use meaningful nam...

A brief analysis of the use of watchEffect in Vue3

Preface Everyone should be familiar with the watc...

Vue's vue.$set() method source code case detailed explanation

In the process of using Vue to develop projects, ...

How to solve the problem of FileZilla_Server:425 Can't open data connection

When installing FileZilla Server on the server, t...

Java+Tomcat environment deployment and installation process diagram

Next, I will install Java+Tomcat on Centos7. Ther...

Mysql implements null value first/last method example

Preface We already know that MySQL uses the SQL S...