创建mysql数据库 CREATE DATABASE IF NOT EXISTS `database_name` DEFAULT CHARSET utf8 COLLATE utf8_general_ci; 创建mysql数据表 drop table if exists `table_name`; create table if not exists `table_name` ( id int auto_increment primary key comment '主键编号', `name` )
视图: 视图是按照你的sql语句生成的一个虚拟的东西,本身并不占数据库的空间 创建视图 create view view_1 as select id from table_1 当你表里的数据增加或者删除的时候,你视图里的内容也随之变化 总之你不能对视图进行update或者insert into操作 说白了,就是视图的变化随着表的变化而变化 除非重新create or replace view_1才能把这个视图中的东西改掉 应用场景:有一个查询语句非常复杂,大概有100行这么多,有时还想把这个巨
--删除表 use [20130823_Recource] go drop table my_table1,my_table2,My_table3 --创建表 use [20130823_Recource] go if(exists(select * from sys.objects where name='Student1')) drop table Student1 go create table Student1 ( Id int primary key identity(1,2) not
INSERT INTO `ftms_active_dealer`(dealer_code,dealer_name,active_id,dealer_state)VALUES('415A1','贺磊'10023','1'), ('31042','魏小彬'10023','1'); [Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server versi
*查询第一条记录:select top 1 * from tablename *随机查询N条记录:select top N * from table order by newid() *判断数据库是否存在:if exists(select * from master..sysdatabases where name='database') *查看数据所有用户表:select * from sysobjects where xtype='u' *判断表是否存在:if exist
查询数据库中所有表名select table_name from information_schema.tables where table_schema='数据库名' and table_type='base table';查询指定数据库中指定表的所有字段名column_nameselect column_name from information_schema.columns where table_schema='数据库名' and table_name='表名'; #查看分布式系统中不同
Sql Server Management Studio没有将table中数据导出为insert语句的功能. 下面一个很有用的存储过程,可以把某张表的数据导出为insert sql语句.当然Oracle.Mysql客户端貌似都已经集成了这项功能.所以本文仅适用于Sql Server Management Studio. USE [testdb] GO /****** Object: StoredProcedure [dbo].[proc_insert] Script Date: 09/30/20