数据库常用命令

来源:互联网 发布:大牌车载香薰 知乎 编辑:程序博客网 时间:2024/04/24 09:21

1. Query table structure;

DB2: select colname, typename, length from syscat.columns where tabname = 'EVT';MSSQL: select a.name, b.name, a.length from syscolumns a, systypes b where a.xtype = b.xtype and a.id = object_id('EVT');Oracle/Mysql: desc tablename;


Oracle:

select COLUMN_NAME,DATA_TYPE from USER_TAB_COLS where TABLE_NAME='MCCOMP_CONFIG';




2. Get first N rows;

Mysql: select * from phone limit NOracle: select * from phone where rownum < NDB2: select * from phone fetch first N rows onlyMSSQL: select top N * from phone 



3. Execute sql scripts via command line;

DB2: db2 -tvf filename;



4. Export ddl of a table:

DB2: db2look -d dbname -e -o phone.txt -t phone -i dmtx -w abcd1234


 

5. Export and import of db data:

db2move rctec export -u dmtx -p abcd1234 [-tn phone]db2move cteclc import -u viacom -p abcd1234


 

6. Connect to MSSQL;

 

sqlcmd -S/SQLEXPRESS -d dbname -U username -P abcd1234


7. Sybase

query stored procedure:

 

select name, uid, type from sysobjects where type='P' and name like '%empplan%'


原创粉丝点击