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