用MySQL创建数据库和数据
表
关于同志近三年现实表现材料材料类招标技术评分表图表与交易pdf视力表打印pdf用图表说话 pdf
:步骤:1、使用show语句找出在服务器上当前存在什么数据库:mysql>showdatabases;TOC\o"1-5"\h\zM+ialiasej:infoi*mation_5chema:■my盘吐L■!per-For-ma.ncbchema.■!S&hlLft!!sns!II/O1*1(1i1+browsinset<0.90sec>2、创建一个数据库test:mysql>createdatabasetest;tnifsql>createdatabasetest;hu&i'yOK,1ironaffect&As&c>3、选择你所创建的数据库:mysql>usetest;ijsq1>usetest;iatal)asechanged4创建一个数据表:首先查看刚才创建的数据库中存在什么表:mysql>showtables;showtables;Empt^set<0.00sec>(说明刚才创建的数据库中还没有数据库表)接着我们创建一个关于students的数据表:包括学生的学号(id),姓名(name),性别(sex),年龄(age)。mysql>createtablestudents(idintunsignednotnullauto_incrementprimarykey,namechar(8)notnull,sexchar(4)notnull,agetinyintunsignednotnull,);createtablestudentsCid.intlirsignednotnullaLito_incrementprimajt'y!key>naiTiecharCS)1notnull^sexcharC4^notnull,agetinyintunsiginednotnull);QuerijOK,0rowsaffected<0.39sec>解释:以"idintunsignednotnullauto_incrementprimarykey"行进行介绍:"id"为列的名称;"int"指定该列的类型为int(取值范围为-8388608到8388607),在后面我们又用"unsigned"加以修饰,表示该类型为无符号型,此时该列的取值范围为0到16777215;"notnull"说明该列的值不能为空,必须要填,如果不指定该属性,默认可为空;"auto_increment"需在整数列中使用,其作用是在插入数据时若该列为NULL,MySQL将自动产生一个比现存值更大的唯一标识符值。在每张表中仅能有一个这样的值且所在列必须为索引列。"primarykey"表示该列是表的主键,本列的值必须唯一,MySQL将自动索引该列。下面的char(8)表示存储的字符长度为8,tinyint的取值范围为-127到128,default属性指定当该列值为空时的默认值。创建一个表后,用showtables显示数据库中有哪些表:mysql>showtables;!r*bles_in_testik+1rawinsec<9.66£ec>5、显示表结构:mysql>describestudents;hysqrl>describestudents:Jid:manesexagre4+4+!NullIKey!Default!Extra■»—<-i\intC10>unsignedi忖0!FBIiNULL::NO:!HULLIcliar><4>INO!!NULLItinyintun?:lgfnedINO■IMULL4-I+T■auto_increnient!Hrows^in>setC®H04sec)6、在表中添加
记录
混凝土 养护记录下载土方回填监理旁站记录免费下载集备记录下载集备记录下载集备记录下载
:首先用select命令来查看表中的数据:mysql>select*fromstudents;mysql>select*fpomstudent?;Emptyset<0.00tcg>(说明刚才创建的数据库表中还没有任何记录)接着加入一条新纪录:mysql>insertintostudentsvalue(01''Tom','''8';h.ysql>ins«ptintostudentsualne(Jlj,>Tom,bucr^1rowAffectedscg>再用select命令来查看表中的数据的变化:mysql>select*fromstudents;RSFsql>select«fromstudents;TOC\o"1-5"\h\z++++IidEisexI1+_(f-h>:1;Ton:F:13;++++1powinact(0.00sec>7、用文本方式将数据装入一个数据库表:创建一个文本文件“student.sq”,每行包括一个记录,用TAB键把值分开,并且以在createtable语句中列出的次序,例如:02TonyF1803AmyM1804LisaM18将文本文件“student.sq”装载到students表中:mysql>loaddatalocalinfile”estudent.sqlintotablestudents;n)jFsql>Loaddatalocalinfile'*e:XX^tudente-aql'^rrtotablestudents;QiiEFyOK,0fomsaffected(Q.00sec^>Records:3Deleted:0Skipped:3Uarnin^s:Q再使用select命令来查看表中的数据的变化:mysql>select*fromstudents;n'fsq'Ly?eLectfi*onistudents;T+-«1r-—一;+!id1■■r■■上r—n&mc!■sex!_■—*—i1STohmiF-g11.——,——.——.+ISi!2!TonyiF1118!i3IAnyIri1118:!41LisaIn|118!!5iII11ui11---I--—1—+5rowsInset<0”盹sec、