显示数据库中的所有表和所有数据库

MSSQL中查询所有数据库

方法1:select * from sysdatabases;

方法2:exec sp_helpdb(使用存储过程查询)

MSQL中查询数据库中的所有表

方法1:select * from sysobjects;

方法2:exec sp_help(使用存储过程查询)

MySQL中查询所有数据库

show databases;

MySQL数据库中查询所有表

show tables;

--------------------------------

插入一个表中的数据有三种方法:

1、insert into student values(5,116,26,90); // 即插入这一行的数据个数、类型一致。 即student里面的所有字段。

或者insert into student(id,name) values(5,116);

2、insert into student set name=116,id=5;

3、复制一个表 insert into student2 select * from student; 

 

------------------------------------

select * from student where classGrent between 20 and 30;

 

------------------------

create database 数据库名;
create table student2(id int(8),name varchar(12),classGrent varchar(12) result varchar(12)); 创建表
------------------
alter table 表名 rename to 新表名
-------------------------------------
更新表中数据
mysql>update MYTABLE set sex="f" where name='hyq'; 

update newstudentinfo set name='zhangsan' where id=1; 

--------------------------------------------------------------

修改表中的某个字段

修改某个表的字段类型及指定为空或非空
>alter table 表名称 change 字段名称 字段名称 字段类型 [是否允许非空];
>alter table 表名称 modify 字段名称 字段类型 [是否允许非空];

>alter table 表名称 modify 字段名称 字段类型 [是否允许非空];

修改字段名:

     alter table     tablename    change   old_field_name    new_field_name  old_type;

 

posted @ 2014-04-22 10:18  kin2321  阅读(3072)  评论(0编辑  收藏  举报