当前位置:网站首页>MySQL review: create tables, MySQL data types, primary key constraints, primary key
MySQL review: create tables, MySQL data types, primary key constraints, primary key
2022-01-15 02:11:51 【YYY speaker】
1. Syntax for creating tables :
create table Table name ();
Create rows and columns in the table :
Name data type primary key, //primary key: This is the primary key. A table can only have one primary key , And no NULL value .( Insertion time , This Sno It can't be NULL) This is Sno It's a primary key constraint , You can modify ( A way of writing )
Name data type ( No addition not null The default value can be NULL)
Name data type
perhaps
Name data type
Name data type
Name data type primary key, // Put the primary key constraint in the last column
create table Student1(
Sno varchar(10) primary key,
name varchar(10),
SSex char(1),
phonenumber varchar(10)
);
If there is no primary key constraint, an error will be reported –primary key
also :not null What does that mean? ?
CREATE TABLE SC(
Sno VARCHAR(5) NOT NULL,
Cao VARCHAR(5) NOT NULL,
Primary key( Sno)
);
Primary key( Sno) This means : The primary key constraint is :Sno This column .( The second way )
Sno VARCHAR(5) NOT NULL, //NOT NULL, The value of this column : You can't have null values , Insert value cannot be empty : Namely NULL;( The default is NULL value )
You can see below :name It can be null
mysql The data type here :
int integer Integers :1,6,11,44,865,78872 wait
VARCHAR(5) A character array amount to char :5 It means that this has 5 A character array of characters .
varchar(10): Yes 10 A character array of characters : Such as : ‘1111’, ‘helloworld’,‘fthwfw’,' written words ’ wait
2. Insert statement :( Method 1)
`
insert into student1 values('1',NULL ,NULL ,NULL);// direct values( Column name variable value , Column name variable value ...);
2. check :
Look up the variables in the table and directly define the table statement :desc Table name ;
Look up the tables in this database : Direct presentation table : show tables;( Before checking Switch database use database )
3. Run script :
mysql>source D:\dp2019\SPJ.txt// There must be :source;(cmd Inside )
版权声明
本文为[YYY speaker]所创,转载请带上原文链接,感谢
https://chowdera.com/2022/01/202201150211479734.html
边栏推荐
猜你喜欢
随机推荐
- Jenkins 通过API获取从节点的secret
- 浅析npm run serve命令
- Push failed Dst refspec V1.0.0 matches more than one.
- 微服务系列--深入理解RPC底层原理与设计实践
- [highcharts] 04_ wrap
- (highly recommended) mobile audio and video from zero to start
- 微服務系列--深入理解RPC底層原理與設計實踐
- Push failed Dst refspec V1.0.0 matches more than one.
- Série de microservices - compréhension approfondie des principes sous - jacents et des pratiques de conception du CPR
- Push failed DST refspec v1. 0,0 matches more than one.
- Analyse de la commande NPM Run Service
- Jenkins obtient le secret du noeud via l'API
- Jenkins API Access Guide
- Quickly write a vs code plug-in
- Yyds dry goods inventory trunk (I)
- Modify a value to make Scrollview and listview elastic and APK volume optimized
- Jenkins exécute le script grovvy via l'API
- Jenkins configure l'affichage chinois (chinois)
- Jenkins Distributed Architecture
- Introduction à Jenkins
- Problème avec les demandes inter - domaines ne portant pas de cookies
- 数据分析八大模型:OGSM模型
- Appel asynchrone, Multithreading
- Android中的羊角符,面试看这个就够了
- Compréhension approfondie du Multithreading
- Utilisation de is et as
- Classe générique, interface générique
- Classe générique, héritage de l'interface générique, délégué
- Exercice de base de données d'accès
- Accès à la base de données SQL avec Multithreading, invoke et action
- Écrire et tester le Protocole Modbus
- . net how to connect to Youxuan database?
- Splitting e-commerce system into micro service
- Écrire un programme winform en utilisant plusieurs threads
- Déclarations SQL couramment utilisées
- Utilisez le texte. Json analyse le fichier json
- Plusieurs adresses de nuget
- Lire Modbus TCP avec nmodbus
- Module 6 operation of the actual combat camp
- TypeError: Object of type ‘TrackedArray‘ is not JSON serializable