alter和alert的一些问题


今天在Java学习群里看到有人问:用alert能不能修改表结构?我第一反应是,alert是弹窗啊,怎么修改表结构?后来再看才知道,是那人打错了!我也晕了一下,还是记一下吧!alter是修改表结构的,alert()是弹出框!

——————————————————————————————————————————————————————————————————————————————

alert弹出框:

<script type="text/javascript">
alert("我是提示文字!");
</script>

——————————————————————————————————————————————————————————————————————————————

MySQL  alter修改数据库表结构用法,出自另位兄台的博客,原文链接:http://blog.sina.com.cn/s/blog_59e0c16f0100w4wj.html。

1.alter操作表字段

(1)增加字段

  alter table 表名 add 字段名 字段类型;

  alter table student add name varchar(10);

(2)修改字段

   alter table 表名 change 旧字段名 新字段名 字段类型;

   alter table student change name name varchar(20)not null default 'liming';//修改字段类型

   alter table student change name name1 varchar(20)not null default 'liming';//修改字段名

(3)删除字段

   alter table 表名 drop 字段名;

   alter table student drop name;

2.alter 索引操作

 (1)增加索引

    alter table 表名 add index 索引名 (字段名1,字段名2.....);

    alter table student add index stu_name(name);

  (2)删除索引

     alter table 表名 drop index 索引名;

     alter table student drop index stu_name;

  (3)查看某个表的索引

     show index from 表名;

   (4)增加唯一限制条件的索引

     alter table 表名 add unique 索引名(字段名);

 3.主键操作

    增加主键:

   alter table 表名 add primary key(字段名);


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM